Hi
i know it has been debated a couple of times on other topics but I wanted to have more solutions or suggestions. I need, due to a very very large number of pages of a certain class, to hide them from the site tree. I don't want neither one of them to be showed, as I will manage them in a custom ModelAdmin type of view.
I'm now using this code:
<?php
class StopHierarchy extends Hierarchy{
public function stageChildren($showAll = false)
{
$baseClass = ClassInfo::baseDataClass($this->owner->class);
$extraFilter = $showAll ? '' : " AND ShowInMenus = 1";
$filter = "`{$baseClass}`.`ParentID` = " . (int)$this->owner->ID;
$filter .= " AND `{$baseClass}`.ID != " . (int)$this->owner->ID;
$filter .= $extraFilter;
if(Director::urlParam("Action") == "getfilteredsubtree" && (!empty($_REQUEST['SiteTreeSearchTerm']) || !empty($_REQUEST['SiteTreeFilterDate'])))
{
// $staged = DataObject::get($baseClass, $filter, "Date ASC");
$staged = DataObject::get($baseClass, $filter, "");
if(!$staged) $staged = new DataObjectSet();
$this->owner->extend("augmentStageChildren", $staged, $showAll);
return $staged;
}
else return new DataObjectSet(); // just Stop
}
}
?>
and then adding to the parent page type of the page type i want to hide:
static $extensions = array("StopHierarchy");
It works, but just out of curiosity: any other suggestion?