Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Martinus

  1. Great! Did not even think about that 🙂
  2. Hi all, I am experimenting on a new site. My page structure: - root / company (rootparent) / north / simple / product - root / company (rootparent) / south / advanced / product template names: - home / company / location / category / product When I am on a product-index page, I retrieve all products going after the template 'product'. I also want the product parents (recursive), AND for only 2 levels. Is this possible with the following code from the docs? foreach($product->parents(true) as $parent) { echo "<li><a href='$parent->url'>$parent->title</a></li>"; } I have also found this code which seems to limit results until the one I use as selector. But that one does not work recursive: $items = $product->parentsUntil('template=company'); foreach($items as $item) { echo $item->name; } Any help is appreciated.
  3. Hi, through Tracy I get the error 'undefined offset: 0, in BatchChildEditor.module.php: 1174 It only happens when adding a new child. Not when I am updating a child. I opened the file and it says: //use the selected template or if none selected then it means there is only one childTemplate option [0], so use that 1174 $childTemplate = $this->wire('input')->post->childTemplate ? $this->wire('input')->post->childTemplate : $pp->template->childTemplates[0]; Is there an update or fix?
  4. I found one solution: if(!($page->rootParent->name === $page->parent->name)) { works for third level.
  5. Hi Zoeck, I forgot to say: I do not know the department-name or the category-name, I only know the page='departments'. department-name = field department, category-name = field category.
  6. My current position in the tree is 'category-name' and I am trying to make a match for it but can't think of what to use: // Root/page=departments/department-name/*category-name*/ if ($page->matches("")) { // we are on third level
  7. @bernhardthanks for pointing me in the direction. It was a bit complicated to find a solution in that topic but apparently there is a simple way. My pages are as follows: Home - Departments -- Department1 --- CategoryA --- CategoryB -- Department2 --- CategoryX --- CategoryY I made one Input Field Type 'Select', type 'page reference', parent set to 'Departments'. I made one input Field Type 'Select', type 'page reference', no parent set, no template set, selector string is 'parent=page.department'. Then it works perfectly. But when I would set a parent for that last field type, the pages using those two dependent fields won't save - so it is best to not set a parent page there.
  8. I have pages like this: Apparel (this is one department option out of 12, for select1) - Clothes (category option for select2) - Footwear (category option for select2) - etc. (category option for select2) As I see it, I need to populate options for select2, depending of chosen option in select1. But I do not want to have 12 select boxes. Does PW not have something to connect the two?
  9. Hi all, Recently I am browsing through the forum and download section. The download section Modules is not really clear to me. Old modules, from 2014, 2015, etc - are they still valid or has time and updates of the core left them behind? I am interested in dynamic selects and I looked at a module from @kongondo in some topic, which is very nice by the way. But, in the download section I could not find it under Pro. Anyway, it was not really clear to me what the benefits were comparing it to the parent=page.something you had to put in a value field somewhere (old post), while Ryan said in an update post all was good now, but still no documentation can be found at this moment. Is it in the core then? Very confusing. Another example, I am looking for a admin theme to use so I can see which field is attached to which page (in columns) but I am afraid to just install anything that slightly resembles what i am looking for. After all, it always says 'at your own risk' and some are just really old. I am spending a large amount of time reading what can be found per module but I am also exhausted because, what am I looking for exactly? I hope I am not offending anyone with these remarks but it would be nice to know where PW stands?
  10. My parent pages are just page-reference fields. But in my approach the Departments displays children under this parent: 'Apparel' etc. And when I click on this child link I get all products under Apparel. Each product has links referring to a category, department, etc.
  11. @Jan Romero I do like the simplicity in your approach !
  12. I actually do not use url-segments for my normal pages. At least, not that I know off. I click the page Departments (menu item or product sub link), and this use the browse template. On the browse template the php switch determines I access a parent page, so I include the parent markup php file (no template), and it displays all children of the Departments: department x, y, z, etc. Same applies to Categories, Sellers and Brands. Since these are actual PW pages they are not url segments. For the sorting, I do use url segments, which, btw, I still have to look at: // Here we use a switch case to determine how to sort. // we are only using 1 URL segment, so send a 404 if there's more than 1 // DO WE NEED TO MAKE A 404 PAGE FOR THIS ??? if(strlen($input->urlSegment2)) throw new Wire404Exception(); switch($input->urlSegment1) { case 'name-asc': // NAME $order = "title"; $sorted = "name asc"; break; etc.
  13. Thanks for responding all. I think I actually have the same as @Guy Incognito My page structure now is (order not important): Home - Departments (parent with each department in it) - Categories (parent with each category in it) - Sellers (parent with each seller in it) - Brands (parent with each brand in it) - Products (parent with each product in it) I use 1 template (browse) for determining what link was clicked (switch case, declaring variables), and 1 template (product) for a single product. In my browse template I include one of two files: for Products or for parents. With markup and all. My browse template is used for all parents and their children. The only thing is, I need occasional dropdown selects with values that are occupied with products. And if I use a direct query on Departments it would be easy but I need only those which have products (I hate pages that says 'nothing found' 😉 I solve this with the following example (some parts can be merged but for simplicity I type it like this): // DEPARTMENT SELECT $select2 = $pages->find("parent=/products/, department>0, sort=name"); // create new array $array2 = array(); // loop through results foreach($select2 as $item) { // move each department in new array array_push($array2, $item->department); // place only unique values in variable $totalDepartments = array_unique($array2); } And then I thought, maybe it was easier moving categories under departments, and products under categories. But maybe I just have to leave it as it is.
  14. I have this code which is working fine only using children of parents: <?php switch($page->parent->name) { case "sellers": case "brands": case "categories": case "departments": // If this page HAS a parent page named 'sellers, vendors, categories or departments'. $items = $pages->find("parent=/products/, seller|brand|department|category=$page, sort=$order, limit=4"); $file = "_products.php"; break; } ?> I am now moving categories under their departments, so, now, my url is this : /sitename/departments/hardware/heating/ Heating is a category under Hardware (which is a department). How do I address the parent of 'hardware' or children of 'hardware' if I do not know it's name? I need to change the switch and also the selector and my question is, how would I make a switch to include my file and retrieve items?
  15. I installed it some weeks ago. I use it, mainly to fix errors, secondly to try and speed up my development site.
  16. Hi thanks for the reply. Is it also possible to have this in a table format? Because when I add fields to display I end up with one long line of text.
  17. Does someone know if you can view more columns in admin? Now in Admin all I have is page names.
  18. It's a pitty no one knows, but maybe I also was in a thinking blib. What I mean is, I can write a value to the field Menu as soon as the page opens the template calculates Food x Drink = Menu. My thoughts where, if it affects the speed to much. Instead why not write to the field without even opening the page? But that was wrong thinking. Sorry for opening this thread 🙄
  19. I have found Concatenate - from 2015 @ryan and do't know if this is for my purpose, but I am afraid installing it because of the message: This module does not indicate compatibility with this version of ProcessWire. It may still work, but you may want to check with the module author. Maybe not even for me since concatenate just adds the fields after each other? I would end up with 'Frites Fanta'?!
  20. Hi, Does anyone know if it's possible to have a 'field value' auto-completed after updating two other fields (in the backend)? Example: I have three fields named Food, Drink and Menu. I give Food a value of Frites, and Drink a value of Fanta, then the Menu value will be filled in automatically with the value of an amount to pay. I could not find info about that. Hope it exist.
  21. ok. I have bootstrap 5.2, and I know the validation of it only checks for empty fields. I still need PW validation at the back. Where do I find such examples? I have looks in the docs, api, and tutorials section (forum) but did not find any.
  22. Hi PW's, I am trying to find out if there is such a thing as a simple contact form with validation etc. on PW. Right now I have a simple form using bootstrap but obvious - there is not really a good validation in it's framework. I could fill in whatever I want and it validates ok. I have looked in modules but there is so much and also many seem to be outdated (more then ten years back). I have tried to install frontendForms but was giving me errors after I placed the folder in my modules map and did a refresh. Any advice is welcome.
  23. @Markus Thomas Thanks! I now have this, which seems to work: <li><a class="dropdown-item" href="<?php echo $page->url;?>name-asc">Name (A-Z)</a></li> It now is forcing the sort options as an urlsegment after the normal url, and the pagination always at the end.
  24. At this link is says how to take care of the urlsegmentstr which is what I did using the switch. https://processwire.com/docs/front-end/how-to-use-url-segments/ The form dropdown button passes exactly what is in the switch in order to do the sort option. Or am I missing something?
  • Create New...