Jump to content

Exclude pages from Insert link > Select Page


Didjee
 Share

Recommended Posts

You probably want to exclude by template for the "Link to URL" autocomplete field too.

// ProcessPageEditLink > Link to URL: exclude pages by template
$wire->addHookBefore('InputfieldPageAutocomplete(name=link_page_url)::render', function(HookEvent $event) {
	$inputfield = $event->object;
	$exclude_templates = ['basic_page', 'movies'];
	$inputfield->findPagesSelector .= ', template!=' . implode('|', $exclude_templates);
});

// ProcessPageEditLink > Select Page / Select Child Page: exclude pages by template
$wire->addHookAfter('ProcessPageEditLink::execute', function(HookEvent $event) {
	$exclude_templates = ['basic_page', 'movies'];
	$css = '';
	foreach($exclude_templates as $template_name) {
		// Hide the page list item (and its children)
		$css .= ".PageListTemplate_$template_name, ";
		// Or just hide the "Choose page" button, if the child pages should remain selectable
		// $css .= ".PageListTemplate_$template_name .PageListActionSelect, ";
	}
	$css = rtrim($css, ', ');
	$css .= ' { display:none !important; }';
	$event->return .= "<style>$css</style>";
});

 

  • Like 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...