Jump to content

Restrict pages in "insert link" autocomplete dialog

Recommended Posts

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 post
Share on other sites

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/';


  • Like 3
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...