Jump to content

OLSA

Members
  • Posts

    151
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by OLSA

  1. @hezmann If this works for you, than I mean that also you can try this example what is in basic the same what Robin S write in first answer: //please note template in selector, in this case go from top to bottom $walk_segments = $pages->find('template=walks, children.children.start_town.marker.continent.title="Europe"'); foreach($walks_segments a as $thewalk){ echo $thewalk->title; }
  2. Hello. Dont know if I understand you well, but maybe this: // get childrens what are in desired continent $europe_walks = $pages->find('template=walk-segments, start_town.continent.title="Europe"'); // or can use selector with continent page id eg. "start_town.continent=10050" $variations = array(); // can use this inside foreach to store page arrays id foreach($europe_walks as $variation){ echo $variation->title . "<br>"; //Walk Segments echo $variation->parent->title . "<br>";//Walk Variation echo $variation->parent->parent->title . "<br>";//Walks } Second option can be this: //directly get walk variations $europe_walks = $pages->find('template=walk-variations, children.start_town.continent.title="Europe"'); Regards.
  3. Hello for all. @Vigilante Maybe this module can help in that situation? How it's works and what it's does: 1. it use customised nestable jquery plugin 2. it clone current PW pages tree 3. provide drag and drop options with parents and childs 4. provide easy option to manipulate with tree (eg. hide children from desired parents) 5. store pages tree list in JSON format, and every list item has attributes (page id and "slug") 6. don't need to build desired website pages tree on-the fly (with complex logic and if statements) in page rendering process Note: to render menu need to create simple function (eg. inside _func.php ) Maybe looks complicated at first sight, but I think it's worth a try. Link to description and download. Regards.
  4. Hello @Kongodo and thanks for this module, I am always in a hurry, and probably that is the reason why I still can't find right solution how to use this field. Please can somebody write short instruction how to get this on attached image using this field? Thanks.
  5. Hello for all, this is old question (and problem) - what is the best option to allow clients to place images inside text in editor field ("body")? Please note that I am not meaning here about default editor image button, because that is bad for administration, clean text data, responsive design etc... My client request is to get them option to create rich content like on many popular world news portals. As one example they want option to insert gallery in some part of text. My answer was that with PW are many, many options how that could be solved - but need to find what is the best for all (user friendly for "editors" (role), clean data storage, manipulation with data and frontend rendering). There are options like using custom markup tags (eg. ![images](1,2,3), or PW Hanna code [[images=1,2,3]]) or another option with repeatable block (editor + image field). What I don't like with markup tags is storing custom (strange) txt format in field, and not so user friendly (could be optimised with custom editor plugin). Using repeatable block can be more user friendly than using macros, but repeatable blocks, are repeatable... and want to avoid later complexity (export, import...). What do you think about custom editor plugin what would insert this: <figure data="1,2,3"><!--data attribute store images ordering number--></figure> In that "empty" figure HTML tag we can store on-page images ordering number using data attribute. To make it visible in editor we can use custom editor.css... That editor plugin can be "button" what would open some modal or popup with options to select on-page image(s). Later in frontend it's not problem to use some PHP HTML parser (eg. Simple HTML DOM Parser) to get and replace figure HTML tag. Please what is your suggestion about this request? Thanks and regards.
  6. Hello, Try to add at the top of your included form1.php this: namespace ProcessWire; Regards.
  7. Bravo diogo! There is no option to give you 10+. Please don't be like others communities where is restricted to tell the true. Processwire is developer oriented platform and need to write code if you want to do custom things. Not like in Joomla or Wordress where you can install template and do things without coding, but also many of us here were there ( for years) but stay with Processwire. Regards.
  8. No, no in this product had very large place for clean categorisation. It is very easy to separate tools and showers or tiles or parquet or painting colors... Except, had that problem on category level, but for that use "tags". As example, in category "Tools" are about 100 products, but also inside that category had tags "for painting", "cleaning"... Also know what are you talking here, as example in some rental site some house can go to rent and sell at the same time (that was my client request in one project). Solved that without problem using "tags". Low level item is property, but same property can have various status... Also property can be house, flat, ship...whatever...
  9. This is off-topic, but here is drag and drop JSON tree page module (or menu manager) what I build inside this project to solve client task to get much as simple solution to manipulate with Main menu (and all other website navigations). Also, please that this topic go in same direction as it started. This is only short of-topic. What this module do: 1: clone page tree and build JSON string (it's good if you have few thousands of pages), and in rendering you don't have in runtime to build main menu 2: if you have some special cases where need to do some correction for main menu, you can do it very fast and easy (do not need to "move" DB large page tree, you "moves" inside small JSON) 3: you can save ("export") somewhere current tree, and experimenting with menu 4: you can create page tree Menu, and child "Top menu", "Sidebars", "Fotter menu" etc... I build this for this project, and main target was to leave real PW page tree, but add options to manipulate with that if needed. Also one of target was to get faster page rendering, done testing (in this project with >2000 pages, get faster pages rendering about 25% and more). How to use it: 1) download attached zip (at the bottom of this message) and install like any other PW module 2) create "JSON tree" type field and place it on some template ("menu", or if you like place it on "home", or...) 3) you can add pages one by one (first tab), or if you have large page tree, in second tab set your "max deep level", set what parent you want to skip their children, and press "Create list" 4) press Save 5) now you can drag and drop and create custom tree (and after changes press save) How to edit some list item: Press on some list item button "pencil/edit", and in the bottom you will get that page selected, change that to some another page... And press Save. How to create "Label" item, in next version that would be different, but now it's can be done: 1) Create template "label" (only title field), create some pages ("labels"), and after select that pages inside JSON tree and append children to it (drag and drop). 2) In rendering process check if template=='label'... How to render page tree (Menu): As example, call: // field is on page with id 3600 // fieldname is "tree" $menu = $pages->get(3600); // var_dump($menu->tree); echo mainMenu( json_decode( $menu->tree)); // mainMenu is method in function.php, there you go through tree and create UL,LI... NOTES: 1) What is inside "mainMenu" function? Do var_dump(...) before function call and will understand what that function need to do. We have JSON objects with attributes, eg. "pwid" store page ID. If you don't build multilanguage websites, you don't have to call PW page (there is also attribute "slug"). // function.php // you need to create function inside function.php // this is only example function mainMenu($items){ $out = ''; foreach( $items as $item ){ // please note main attribute "pwid" it's store PW page id $i = wire('pages')->getById($item->pwid)->first();// in my example need this because multilanguage project . . . . } } This module is totally unpolished (first version). Here are few screenshots: - First image shows process when module clone PW page tree where you can add desired pages to list. - Second image shows option where you can add pages one by one, or select multiple and add. - Third image shows what happened after you press button "Add to list" or "Create list". Regards. FieldtypeJSONtree.zip
  10. Thank you Zeka, Can't use this concept because, as example, they have category "faucets", and there are "faucets" for kitchen and for bathroom. Also they have "colors" for wall paintings, "floors" (wall tiles for kitchen or bathrooms can be the same product), and there are other examples where can't use that principle (divide products by area)... Also, grouping categories really helps to get cleaner administration, but also get me in another "problem" where I get unbalanced page tree (levels), as example: 1) products: - faucets ---- faucet-product-1 ---- faucet-produc-2 . . - floors ---- parquet -------- parquet-product-1 ---- laminate -------- laminate-product-1 I use PW few years, and build many custom things (not polished yet to put it here, but will do it for this great/the best community), but never use PW concept with URL segments. Read about that, sounds to me very interesting, but never had time to investigate, how and when... Yes thinking about that, but that not decided to use that concept because in administration would be chaos (initial content is ~2000 products, but client has plan to place 10 to 20 000 products, build importers..). Also for ajax, filters.. in backend is "easier"... "where parent category is my parent"... In all I agree with you, but sorry because in first topic, I didn't write other details about this website. Thanks.
  11. Hello for all, these days finishing project what is combination of e-commerce and portal website. Problem is "Products" page-tree because content need to be divided inside 48 categories. Also the client gave me content divided in 68 categories, but at the end they accepted my proposal about reducing that number. But problem is that and with 48 categories in backend, "Products" page tree is very large, long list, and very hard for administration. On front-end mega-menu with labels (menu group headings) solved that problem for vistors. And, at the end, I decided to test variant with additional categories to group categories, and result is good (now it's easy for adminsitration to find what they want very easy). Problem: now urls are longer, and in some parts (categories) not sure how that's can affect on SEO (eg. before: "products/showers/some-product", now: "products/showers-and-bathtubs/showers/some-product"). There are few more examples like that. And another thing is that urls are now longer (more characters, and deeper). For better administration I added new level of categorisation - I think - that is not a way to go. What is your opinion or suggestion about that? Maybe different, custom admin template, with custom navigation, or some folders? or ...? Thanks.
  12. Thank you Robin S! "status=published" solved my problem. I was sure that eg. outlet=0 or outlet='' will work and didn't think that there might be some new selectors (need to read this). No everything need to be simple as possible. If in edit procedure product doesn't have visible group - it's not in a group. Group is "virtual" product item (can change...), not like "TV" or "sofa", and because of that administration can do with group what they like (eg. update: change image and append new product to group). Probably, after they sell "group item", they will delete group page. Here is more important to delete real products (if no products, no group) . Ok, very interesting, will try it. Thanks Robin S.
  13. Hello for all, sorry for this topic title but let me try to explain. Website has product items, where sometimes products go to "Outlet" (actions/discounts). Main part here is that in "action" status: a) product can have new price and go alone to discount OR b) product is in group with other products ("collection", and new price is only valid in case when customer buy full collection). First problem was how to get this : Product items: A on action B on action in group with "D" C on action D on action in group with "B" --------------------------------------------------- Outlet list page need to show 3 items: 1. item (A) 2. item (B, D) (eg. item image is "TV+sofa") 3. item (C) First what I done, was that I created Outlet "category" with children, where children page has fields: title, group image and page select field (to select products from another page tree). But that was wrong and dirty (few foreach, pagination..., etc. that was bad concept). Than I decided to place page select field on product item, and from product item select it's group (single select field). And that was ok, and I like it also because administration in any variant need to go to product to set new price. Right now, administration first create group page with some title and with some image. After that, go to product item, check field "action", write new price, and - if - product is part of group - add - it to group. There is part of code on "Outlet" list page: // outlet-list.php // $items: single items // outlet: page field, it's parent is "Outlet" list page $items = $pages->find('template=product-item, action=1, outlet.count=0'); // outlet=0 or outlet=''... $group_items = $pages->find('template=product-item, action=1, outlet.count>0'); // group items ("merge") foreach( $page->children() as $group ){ // go through Outlet children ("group id pages") if($group_items->has("outlet=$group->id")){ // if in array are items with that group id $group->singles = $group_items->find("outlet=$group->id"); // append to page "group" new attribute and fill it $items->add($group); // now go back and append to "items" new type of "item" } } // pagination $pagination = $items->renderPager(); After it in rendering process I get basic product items, and "group" items together inside list page. Here is the problem: When I go and set some of Group page as "unpublished", I expect, after it, to get that group subitems shows as alone (singles) inside Outlet. But not. They doesn't shows!? In that case outlet.count return null, but real "singles" return false. I try more options with selector (and different page select field types) but can't get what expect to be. // selector to return singles 'template=product-item, action=1, outlet.count=0' // tried options outlet=0, outlet='', outlet=0|"", outlet.count<1 etc... Sorry for this long, long topic. If someone has some idea what and where... I would be grateful Best regards! p.s. if all this is confused, last sleeping was... can't remember
  14. Hello for all, don't know If I understand You well, but if you are using PW inputfields (modules/API) to build form, than to remove label from some field need to do that in two small steps. First set field label as blank (""), and after it set option "skiplabel" to "true". Example: $myfield->label = ''; $myfield->skipLabel = true; Regards.
  15. Hello for all, also had problem with this warning, and read this and this and find why that's added in PW. My problem was that I don't have CPanel permissions (only to login to website admin/backend). Website is multilanguage (3 languages, Montenegro, English and Russian) and try few options for all languages, but always after logout/login get warning message. There is little confused note: "Default is 'C'. Specify '0' to skip the setlocale() call (and carry on system default)." I try with "0" to all, but that don't solve problem. Also not sure about "C", maybe need to change note to this: "Specify 'C.UTF-8', or '0' to skip the setlocale() call (and carry on system default)." Because webiste is hosted on one of the popular european hosting providers, I assumed that there is probably set_locale supported/installed for languages like English, and Russian, but not sure about Montenegro, and try this: Montenegro: C.UTF-8 English: en_US.UTF-8 Russian: ru_RU.UTF-8 And that fix problem. Regards.
  16. Hello for all, I created "admin" role and what I want for that rolle is just restriction to see "Admin" and "system/tools" page tree, but also option to delete pages from list tree. +1 for delete permission
  17. Hello, today I need this and try adrian and Soma solutions but with partial success (PW 3.0.42). Finally solved with this: wire()->addHookBefore('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments('page'); if($page->template != "your_specific_template_name") return; if($page->isChanged('your_target_field_name')){ // your code $this->message('Your message about changes...'); } }); Main difference is "changes" argument, or $page->isChanged('some_field_name') Regards.
  18. Hello Brian. Just saw only two files and here are small suggestions for better practice ( pages->find inside foreach and count inside for loops). insider-home.php // line 2. foreach ($pages->find("articleInsider=1") as $article){ ... } better is this: $articles = $pages->find("articleInsider=1"); foreach ($articles as $article){ ... } or article.php // 46. line for ($i=0; $i < count($titleArr); $i++) { ... } to this $c = count($titleArr); for ($i=0; $i < $c; $i++) { .... } It's not problem if do this inside if statement eg. if( count($pages->find...) > 1 ). Regards.
  19. Hello Vikestart, for that you can use "tags". To create "tags" there are many options and here is one: 1) create template "tags" 2) create template "tag" with only deafult field "title" 3) create field "tags", type page ( my suggestion is to use Lostkobrakai module Chosen Select ), and add it to "movie" template *** note: for page field "tags" set as parent page "Tags" (example below) As example here is some page tree: - Home - About Us - Movies --- Horror ------ Some Horror Movie (eg. template "movie" with your custom fields - and one is field "tags" (3.) ) --- Thriller ------ Some Thriller Movie ( -//- -//- -//- ) - Contact - Tags ( template: "tags", page/settings: hidden ) --- Horror (template: "tag") --- Thriller (-//-) --- Scifi --- etc After that inside movies set "tags" for every movie (one or multiple tags per movie). 1) Here is example how to get Some Horror-Thriller inside your category Thriller's: // on page "Thriller" $search_term = $sanitizer->text($page->title); // thriller $items = $pages->find("tags.title%=$search_term, sort=-sort"); // here you can add more precious filters... 2) You have some "Tags Cloud" widget (eg. in some sidebar) <?php // tags cloud $tags = $pages->find("template=tag, include=all");// include=all because of hidden parent ?> <div class="widget tags-cloud"> <?php foreach($tags as $tag): ?> <a href="<?php echo $tag->url;?>"><?php echo $tag->title;?></a> <?php endforeach; ?> </div> Maybe links inside "tags-cloud" are little confused, eg. "my-website.com/tags/horror" but that's part will be more clear if you watch main part inside tag.php and tags.php templates (below): // tag.php $search_term = $sanitizer->text($page->title); $items = $pages->find("tags.title%=$search_term, sort=-sort"); // tags.php $tags = $pages->find("template=tag"); $items = $pages->find("tags=$tags, sort=tags.title"); regards p.s. this principle is used here on some of my testing website (at sidebar column is tags-cloud widget)
  20. Hello, my problem was that I get blank page after manual upgrade from 2.8.0/2.8.35 to 3.x. on localhost (Windows). Also there is no errors inside log files (php, apache... site/logs). Problem solved after addition in top of config file (site/config.php): namespace ProcessWire; One of the first thing what I done (after upgrade and blank page) was that I added this in site/config.php : // no need to add this!!! // disable module compilation $config->moduleCompile = false; // disable template file compilation $config->templateCompile = false; but did not pay attention on config file, and "configure" itself . Regards. p.s. maybe this should be noted in this page
  21. Hello, don't want to open new topic, but can confirm similar problem. In localhost, I have problem to upgrade from 2.8.35 to 3.0.42 (also unsuccessful to 3.0.51), but clean install 3.0.42 go without any problem. I have totally blank page and don't have any error inside log files (php, apache, mysql and also PW error log file are clean)!? Also try many reloads (Ctrl+F5) but without success. A few details about my local server: PHP 5.6.16, MySQL 5.7.9, Apache 2.4.17, Wamp 3.0.0 Regards. EDIT: solved problem after addition "namespace ProcessWire;" on top of the site/config.php (more details here)
  22. Hello for all, I can't find solution how to manipulate with image tags field (as object) inside admin/edit using hooks. My problem that I need to use multilanguage predefined tags (I like to store pages ID from some another page tree). Also I know that there are other solutions (eg. repeatable field with image field and some page field for tags, or using page table), but in my case I like to use hook inside custom module for that job. I try with InputfieldImage::render, and InputfieldFile::render... but with that I can't get/"touch" values from image tags field. Only working solution what I have right now is using ProcessPageEdit::execute but with that can manipulate only with tags value - is there any other better elegant solution to manipulate with image tags field (as object, as example set class, add readonly attribute, append some html...)? $this->addHookBefore('ProcessPageEdit::execute', function(HookEvent $event) { $page = $event->object->getPage(); foreach ( $page->fields as $field ) { if ($field->type instanceof FieldtypeImage && $field->useTags) { $imageField = $page->get((string)$field->name); // there are multiple images foreach($imageField as $f){ $f->tags = '...'; // tags value only } } } }); Regards and thanks. EDIT: Now it's clear to me what can be done. With this ("simple" variant) is possible to add class to wrapper, manipulate with value, but for more than that need to override core InputfieldFile module (inside site/modules). Also there is always option to use javascript for some manipulation.
  23. I assume that you know how to show field label on front (there is few options), one option is: echo $page->fields->summary->label; // for field with name "summary" But today I had a problem how to show field label depending on the current page template (example: in template "member", "summary" field label is override to "Personal info"). In that case, previous example will not give you desired result. To get field label in that case, this is what works: $page->getField('summary')->label; // result would be "Personal info" Maybe this is helpful for someone. Regards.
  24. Hello for all, don't know if this is interesting to someone: //pseudocode example (inside some module) //we have some pages array (5 to 10 pages) wire('pages')->find('id=1111|2222|...'); // 0.050s, and ordering is not like selected wire('pages')->getById( array(1111,2222,...) ); // 0.035s, and ordering is exactly like selected It seems that query with "getById" is somehow faster and ordering is correct. Regards
  25. Hello, I have the same problem today and done this to solve that: $your_field->label = ''; //first need to set field label as empty string (important!) $your_field->skipLabel = true; //works only if the label is set to empty string regards.
×
×
  • Create New...