Jump to content

page Referenz - selectable Pages


itsberni
 Share

Recommended Posts

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

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");
  }
});

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...