/** * Returns a page that acts as the root node for a navigation block. * * @return SilvercartProductGroupPage * * @author Sascha Koehler <*****@*****.**> * @since 26.05.2011 */ public function Navigation() { if (!$this->SilvercartProductGroupPageID) { return false; } $productgroupPage = SilvercartProductGroupPage::get()->byID($this->SilvercartProductGroupPageID); if (!$productgroupPage) { $productgroupPage = SilvercartProductGroupHolder::get()->byID($this->SilvercartProductGroupPageID); } if (!$productgroupPage) { return false; } $currentPage = Controller::curr(); $branchSitetree = SilvercartTools::getPageHierarchy(Controller::curr()); $productgroupPageSiteTree = ModelAsController::controller_for($productgroupPage); $navigation = ''; foreach ($productgroupPageSiteTree->Children() as $childPage) { $navigation .= $this->renderProductGroupNavigation($childPage, $currentPage, 0, $branchSitetree); } if (empty($navigation)) { $hasNavigation = false; } else { $hasNavigation = true; } return new DataObject(array('RootPage' => $productgroupPageSiteTree, 'HasMenu' => $hasNavigation, 'Menu' => $navigation)); }
/** * Load the page hierarchy. * * @param array|null $record This will be null for a new database record. * @param boolean $isSingleton Set this to true if this is a singleton() object, a stub for calling methods. * * @author Sascha Koehler <*****@*****.**> * @since 2012-12-10 */ public function __construct($record = null, $isSingleton = false) { parent::__construct($record, $isSingleton); $this->pageHierarchy = SilvercartTools::getPageHierarchy(Controller::curr()); }