Exemplo n.º 1
0
 /**
  * Render Category Page
  * @throws CHttpException category not found
  * @param $name
  */
 public function actionView($name)
 {
     $model = Category::model()->findByAttributes(array('alias' => $name));
     if ($model === null) {
         throw new CHttpException(404, 'Запрашиваемая вами страница не найдена.');
     }
     if ($model->isLeaf()) {
         $category = Category::model()->with(array('attrGroups' => array('select' => 'id'), 'attrGroups.attrs' => array('select' => 'name,type,template'), 'attrGroups.attrs.attrValues' => array('select' => 'value', 'order' => 'value')))->find(array('condition' => 'alias="' . $name . '"', 'select' => 'id,name', 'order' => 'attrs.global_pos'));
         $this->render('goods', array('category' => $category, 'brands' => Brand::GetCategoryBrands($category->id)));
     } else {
         $models = $model->children()->findAll();
         $this->render('catalog', array('models' => $models, 'cat' => $model));
     }
 }