getConfig('type')) { $this->_action = 'subpages'; } return parent::exec(); } protected function _doView() { $item = array( 'siteMap' => Qs_SiteMap::get4Userend(), 'tpl' => $this->getTemplate('view.tpl') ); $item['siteMapPagesCount'] = App_Cms_Obj::getInstance()->getSiteMapPageCount($item['siteMap']); $this->_addItem($item); return $this; } protected function _doSubpages() { $blockData = [ 'pageId' => $this->getConfig('pageId') ]; if (($item = $this->getSideBlockItem($blockData))) { $item['tpl'] = $this->getTemplate('subpagesPageBlock.tpl'); $this->_doc->addItem($item); } } protected function _getRootPage($pageId) { $list = array(); $sitemap = Qs_SiteMap::getFull(); Qs_Array::treeWalk($sitemap, function ($page) use (&$list) { if (isset($page['id'])) { $list[$page['id']] = $page; } }); while (isset($list[$pageId])) { $page = $list[$pageId]; $pageId = $page['idParent']; if (0 === (int) $page['idParent']) { return $page; } } return null; } public function getSideBlockItem(array &$blockData = array()) { EventView::initFullSitemap(); $item = array(); if (empty($blockData['pageId'])) { /** @var Qs_Doc $doc */ $doc = Zend_Registry::get('doc'); if (!($pageId = $doc->getOption('idParent'))) { // show parent pages if first level page $pageId = $doc->getOption('id'); } $item['page'] = Qs_SiteMap::findFirst(['id' => $pageId]); } else { $item['page'] = Qs_SiteMap::findFirst(array('id' => $blockData['pageId'])); } if (empty($item['page']['sub'])) { return null; } $blockData['title'] = $item['page']['title']; Qs_Array::treeWalk($item['page']['sub'], function ($page) { return $page['showInSubmenu'] == 'y' && $page['enabled'] == 'y' && ($page['redirect'] != 'y' || ($page['redirect'] == 'y' && $page['idParent'] != 0)); }); if (empty($item['page']['sub'])) { return null; } $item['tpl'] = $this->getTemplate('subpagesSideBlock.tpl'); return $item; } }