Skip to content

Instantly share code, notes, and snippets.

@dsdsdsdsdsds
Created November 10, 2019 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsdsdsdsdsds/016b8ec1b88a0675b1c85b5c490bb900 to your computer and use it in GitHub Desktop.
Save dsdsdsdsdsds/016b8ec1b88a0675b1c85b5c490bb900 to your computer and use it in GitHub Desktop.
ProcessWire: Hide non-editable pages in the page tree
<?php namespace ProcessWire;
// Taken from https://processwire.com/talk/topic/22369-hide-uneditable-pages-in-admin-treeprocesspagelist/?tab=comments#comment-191963
$this->addHookAfter('ProcessPageList::find', function(HookEvent $event) {
$pages = $event->return;
$excludePagesByTemplate = array('admin', 'basic-page');
$pages->each(function($p) use($pages, $excludePagesByTemplate) {
if(!in_array($p->template, $excludePagesByTemplate)) return;
if(!$p->editable() && !$p->addable()) $pages->remove($p);
});
$event->return = $pages;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment