bartelsmedia Posted March 28, 2019 Share Posted March 28, 2019 The autocomplete feature of the "link insert" is absurdly useful. However it quickly becomes flooded with similar sounding pages in my setup. Is there a way to filter/exclude certain branches of the page tree from here? I tried this setting for the unwanted "/menu/" branch but it still shows up: In an ideal world, each "insert link" dialog would be customizable. Example: The "insert page"dialog fro a page under "/faq/" would show only URL matches of page tree branch "/tech/", etc. Does this make sense? Link to comment Share on other sites More sharing options...
Robin S Posted March 28, 2019 Share Posted March 28, 2019 You can use a hook like this in /site/ready.php: $wire->addHookBefore('InputfieldPageAutocomplete(name=link_page_url)::render', function(HookEvent $event) { $inputfield = $event->object; // Get the page being edited $page_id = $event->wire('input')->get->int('id'); $edited_page = $event->wire('pages')->get($page_id); // If the edited page is one that you want to target if($edited_page->template == 'basic_page') { // Append to the findPagesSelector property to exclude pages you don't want to match $inputfield->findPagesSelector .= ', has_parent!=/menus/'; } }); 3 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