protected function findModel($id)
 {
     if (($model = PageCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 public function actionDetail($id)
 {
     $view = LuLu::getView();
     $model = $this->findModel($id);
     $view->setTitle(empty($model['seo_title']) ? $model['title'] : $model['seo_title']);
     $view->setMetaTag('keywords', $model['seo_keywords']);
     $view->setMetaTag('description', $model['seo_description']);
     $view->addBreadcrumb('页面', ['page/index']);
     $category = PageCategory::findOne($model->category_id);
     if ($category !== null) {
         $view->addBreadcrumb($category['name'], ['page/index', 'catid' => $category['id']]);
     }
     $view->addBreadcrumb($model['title']);
     $locals = [];
     $locals['model'] = $model;
     $locals['catid'] = $model->category_id;
     $locals['currentCategory'] = $category;
     $detailTpl = $this->getDetailTpl($model['tpl']);
     return $this->render($detailTpl, $locals);
 }