update AG Posted September 27, 2021 Share Posted September 27, 2021 Until now, I have set $parent_id in page selection fields (InputfieldPage) that have different root directories depending on the page being edited, with the following hook: $wire->addHookAfter('InputfieldPage::findPagesCode', function($event) { if(substr_count($event->object->name, 'select_focus_page') > 0) { $page = $event->arguments('page'); $return = $event->return; $parent_id = wire('input')->id; $event->return = wire('pages')->get($parent_id); } }); Now I see in inputfieldPage.module that the function 'findPagesCode' is deprecated. We are supposed to use the 'getSelectablePages' function instead. However: I haven't figured out how to use 'getSelectablePages' to set the $parent_id with a hook. Has anyone had more success with this? Translated with www.DeepL.com/Translator (free version) Link to comment Share on other sites More sharing options...
kixe Posted September 27, 2021 Share Posted September 27, 2021 Make child pages of page beeing edited selectable in a page field named: nameOfTheField $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'nameOfTheField') { $event->return = $event->pages->find('parent=' . wire('input')->get->id); } }); 2 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