function actionIndex($params = '') { $objPage = new PagesModel(); $objLayout = new LayoutModel(); $page_id = !empty($params['page_id']) ? intval($params['page_id']) : 0; $previewPage = !empty($params['preview']) ? true : false; if (empty($params['page_id'])) { $page_id = $objPage->getPageId('home'); } $pageInfo = $objPage->loadPage($page_id); if (!empty($pageInfo) && $pageInfo['status'] == 'published' && $pageInfo['type'] == 'page' || $previewPage == true) { // load additional page info $sideBars = $objPage->getPageSidebars($page_id); $layoutInfo = $objLayout->loadLayout($pageInfo['layout_id']); // used to set active state in menu $this->view->current_page = $pageInfo['keyName']; //assign template vars $this->view->assign('pageTitle', $pageInfo['title']); $this->view->assign('content', $this->view->fetch('fromstring:' . $pageInfo['content'])); if (!empty($sideBars)) { $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $sideBars['left']['content'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $sideBars['right']['content'])); } $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code'])); } else { // page not found $this->view->assign('layout', '404 - ' . print_r($params, true)); } $this->finish(); }
function smarty_function_menu($params, &$smarty) { $output = ''; $objPages = new PagesModel(); $pageList = $objPages->getPages('published'); global $__pageListTemp; if (!empty($pageList)) { // limit to a parent if (!empty($params['parent'])) { // find parent $parent_id = $objPages->getPageId($params['parent']); if ($parent_id) { smarty_function_menu_parent($pageList, $parent_id); $pageList = $__pageListTemp; } } reset($pageList); // limit depth if (!empty($params['depth'])) { $depth = intval($params['depth']); $pageList = smarty_function_menu_setdepth($pageList, $depth); } reset($pageList); // remove specific pages if (!empty($params['remove'])) { $params['remove'] .= ',404'; } else { $params['remove'] = '404'; } $pageList = smarty_function_menu_removepages($pageList, $params['remove']); reset($pageList); // set active classes if (!empty($smarty->current_page)) { $pageList = smarty_function_menu_makeactive($pageList, $smarty->current_page); } reset($pageList); // draw menu $output = smarty_function_menu_makemenu($pageList, $output, $smarty); } return $output; }