/** * Generates the sitemap for the given root page * * @param SiteTree $page Page to get map for * * @return string * * @author Sebastian Diel <*****@*****.**> * @since 25.04.2012 */ public function generateSiteMap($page) { $page->SiteMapChildren = ''; if ($page->Children()->count() > 0) { foreach ($page->Children() as $child) { if ($child->ShowInMenus) { } $child->SiteMapChildren .= $this->generateSiteMap($child); } } $output = $page->renderWith('SilvercartSiteMapLevel'); return $output; }
/** * Renders the product group navigation. * * @param SiteTree $rootPage The root page to start with * @param SiteTree $currentPage The current SiteTree object * @param int $level The current level * * @return string * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**> * @since 24.11.2014 */ public function renderProductGroupNavigation($rootPage, $currentPage, $level = 0) { $renderStr = ''; $isActivePage = false; $level++; if ($this->levelsToShow == 0 || $level <= $this->levelsToShow) { if (!($this->expandActiveSectionOnly && ($this->levelsToShow != 0 && $level > $this->levelsToShow || $level > 1) && SilvercartTools::findPageIdInHierarchy($rootPage->getParent()->ID) === false)) { $childPages = $rootPage->Children(); $childPageStr = ''; if ($childPages && $childPages->Count() > 0) { foreach ($childPages as $childPage) { $childPageStr .= $this->renderProductGroupNavigation($childPage, $currentPage, $level); } } if (Controller::curr()->ID === $rootPage->ID) { $isActivePage = true; } if (SilvercartTools::findPageIdInHierarchy($rootPage->ID) || $rootPage->ID === $currentPage->ID) { $isActiveSection = true; } else { $isActiveSection = false; } $data = new ArrayData(array('MenuTitle' => $rootPage->getMenuTitle(), 'Title' => $rootPage->getTitle(), 'Link' => $rootPage->Link(), 'LinkOrSection' => $rootPage->LinkOrSection(), 'ChildPages' => $childPageStr, 'IsActivePage' => $isActivePage, 'IsActiveSection' => $isActiveSection, 'Level' => $level)); $renderStr .= $data->renderWith('SilvercartProductGroupNavigationWidgetEntry'); } } return $renderStr; }
/** * Renders the navigation. * * @param SiteTree $rootPage The root page to start with * @param int $level The current level * * @return string * * @author Sascha Koehler <*****@*****.**> * @since 22.05.2012 */ public function renderNavigation($rootPage, $level = 0) { $renderStr = ''; $isActivePage = false; if ($this->getLevelsToShow() != 0 && $level > $this->getLevelsToShow()) { return $renderStr; } $childPages = $rootPage->Children(); $childPageStr = ''; if ($childPages->exists()) { $childLevel = $level + 1; foreach ($childPages as $childPage) { if ($childPage->ShowInMenus) { $childPageStr .= $this->renderNavigation($childPage, $childLevel); } } } if (Controller::curr()->ID === $rootPage->ID) { $isActivePage = true; } $showChildPages = false; $isSectionPage = false; if (SilvercartTools::findPageIdInHierarchy($rootPage->ID)) { $showChildPages = true; $isSectionPage = true; } if (method_exists($rootPage, 'OriginalLink')) { $link = $rootPage->OriginalLink(); } else { $link = $rootPage->Link(); } if ($rootPage->ID === $this->getStartPage()->ID) { $isRootPage = true; } else { $isRootPage = false; } $data = array('MenuTitle' => $rootPage->getMenuTitle(), 'Title' => $rootPage->getTitle(), 'Link' => $link, 'ShowChildPages' => $showChildPages, 'ShowSiblings' => $this->showSiblings, 'ChildPages' => $childPageStr, 'IsActivePage' => $isActivePage, 'IsSectionPage' => $isSectionPage, 'IsRootPage' => $isRootPage); $parser = new SSViewer('SilvercartSubNavigationWidgetEntry'); $renderStr .= $parser->process(new DataObject($data)); return $renderStr; }