Didjee Posted October 1 Share Posted October 1 I want to exclude pages with certain templates from Insert link > Select Page. Is this possible using a hook? Link to comment Share on other sites More sharing options...
Robin S Posted October 2 Share Posted October 2 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>"; }); 1 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