itsberni Posted December 27, 2017 Share Posted December 27, 2017 Hi, i´ve got the following site-structure:- Project 1 - item 1 - item 2 - item 3 - subitem 1.3.1 ( includes optionfield "switched" ) - subitem 1.3.2 ( includes optionfield "switched" ) - subitem 1.3.3 ( includes optionfield "switched" ) - item 4 ( pageReferenz - field )- Project 2 - item 1 - item 2 - item 3 - subitem 2.3.1 ( includes optionfield "switched" ) - subitem 2.3.2 ( includes optionfield "switched" ) - subitem 2.3.3 ( includes optionfield "switched" ) - item 4 ( pageReferenz - field ) now i create a page reference field and as a selector i defined "switched=1". So i want to bring out all pages (subitems) from the page tree "Project 1" OR "Project 2". But as a result i will get now all the pages (subitems) from project 1 + 2. Formulated differently - i only want to get the pages from Project 2, when i am in item 4 of Project 2 How can avoid the results from the tree, i am not in? Thanks a lot! Link to comment Share on other sites More sharing options...
dragan Posted December 27, 2017 Share Posted December 27, 2017 has_parent=parent ? Link to comment Share on other sites More sharing options...
itsberni Posted December 27, 2017 Author Share Posted December 27, 2017 Added to „selector string“ - brings out no results in any case. thanks..... Link to comment Share on other sites More sharing options...
Klenkes Posted December 28, 2017 Share Posted December 28, 2017 It would have to be something like: $pages->find("has_parent=$page->parent, template=subitem-template, switched=1"); Link to comment Share on other sites More sharing options...
itsberni Posted December 28, 2017 Author Share Posted December 28, 2017 Unfortunately, no... As part of pageReferenz i think i have to write "has_parent=parent, template=subitem-template, switched=1". But even this attempt failed - no results in that case....thanks anyway Link to comment Share on other sites More sharing options...
elabx Posted December 28, 2017 Share Posted December 28, 2017 Don't know if I am getting ahead of myself but the custom code option to get the selectables could be like this (this code can be placed in site/ready.php as per the field's instructions): $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'page_reference_field') { //the page instance where the field exists, in this case, Item 4 for example $page = $event->arguments('page'); //the reference to the project $currentProject = $page->parent('template=project'); //has_parent sets the parent limit for the find() $event->return = $event->pages->find("has_parent=$currentProject,template=subitem_template"); } }); 1 1 Link to comment Share on other sites More sharing options...
Robin S Posted December 29, 2017 Share Posted December 29, 2017 For the "Selector string" option I think the correct syntax is: has_parent=page.parent 1 Link to comment Share on other sites More sharing options...
itsberni Posted December 29, 2017 Author Share Posted December 29, 2017 elabx, many thanks! Your solution does it. Works perfectly! Many thanks to all of you! Happy new year! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now