/** * @menuLabel display root content page * @menuIcon <span class="glyphicon glyphicon-list-alt"></span> */ public function actionHomepage() { $currentLanguageId = Yii::$app->controller->module->getLanguageManager()->getLanguageIdForString(Yii::$app->language); $pageContent = null; $isFallback = false; $menuItemForRoot = CmsMenuItem::findOne(['cms_hierarchy_item_id' => DefaultController::$ROOT_HIERARCHY_ITEM_ID, 'language' => $currentLanguageId]); if ($menuItemForRoot == null) { $menuItemForRoot = CmsMenuItem::findOne(['cms_hierarchy_item_id' => DefaultController::$ROOT_HIERARCHY_ITEM_ID]); $isFallback = true; } if ($menuItemForRoot != null) { $pageContent = CmsPageContent::findOne(['id' => $menuItemForRoot->page_content_id]); } if ($pageContent == null) { throw new NotFoundHttpException('No content could be found for the given id', 404); } return $this->render('page', ['pageContentModel' => $pageContent, 'isfallbacklanguage' => $isFallback]); }
/** * @menuLabel display root content page * @menuIcon <span class="glyphicon glyphicon-list-alt"></span> */ public function actionHomepage() { $currentLanguageId = Yii::$app->controller->module->getLanguageManager()->getLanguageIdForString(Yii::$app->language); $pageContent = null; $isFallback = false; $menuItemForRoot = CmsMenuItem::findOne(['cms_hierarchy_item_id' => DefaultController::$ROOT_HIERARCHY_ITEM_ID, 'language' => $currentLanguageId]); if ($menuItemForRoot == null) { $menuItemForRoot = CmsMenuItem::findOne(['cms_hierarchy_item_id' => DefaultController::$ROOT_HIERARCHY_ITEM_ID]); $isFallback = true; } if ($menuItemForRoot != null) { $pageContent = CmsPageContent::findOne(['id' => $menuItemForRoot->page_content_id]); } if ($pageContent == null) { throw new NotFoundHttpException('No content could be found for the given id', 404); } Yii::$app->view->params['currentHierarchyItemId'] = $menuItemForRoot->cmsHierarchyItem->id; if (Yii::$app->controller->module->assembleBreadcrumbInformation) { Yii::$app->view->params['breadcrumbHierarchyItemPath'] = []; } return $this->render('page', ['pageContentModel' => $pageContent, 'isfallbacklanguage' => $isFallback, 'renderTopMenuNavbar' => Yii::$app->controller->module->renderTopMenuNavbar]); }
/** * Finds the CmsMenuItem model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * @return CmsMenuItem the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CmsMenuItem::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }