public function loadModel($id)
 {
     if (($model = FaqQuestion::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
 public function actionIndex($path = '', $tag = null)
 {
     // Загружаем список категорий верхнего уровня
     $categories = FaqCategory::model()->root()->published()->findAll(array('order' => 't.sort ASC'));
     // Категория FAQ
     if ($path == '') {
         $category = !empty($categories) ? $categories[0] : null;
     } else {
         $category = FaqCategory::model()->published()->findByPath($path);
     }
     if (is_null($category)) {
         throw new CHttpException(404);
     }
     // Если выбран тег
     if ($tag !== null) {
         $questions = FaqQuestion::model()->withTag($tag)->published()->findAll(array('order' => 't.sort ASC'));
         $this->render('list', array('categories' => $categories, 'category' => $category, 'questions' => $questions, 'tag' => $tag));
     } else {
         $this->render('index', array('categories' => $categories, 'category' => $category));
     }
 }
Пример #3
0
 public function withTag($tag)
 {
     return FaqQuestion::model()->taggedWith($tag);
 }