public function actionEdit($id) { $this->pageTitle = Yii::t('app', 'Редактирование категории'); $model = ShopCategories::model()->findByPk($id); if (!$model) { throw new CHttpException(404, Yii::t('app', 'Категория не найдена')); } //var_dump($model->url);die; // var_dump($model->path);die; //var_dump($model->breadcrumbs); //die; $this->breadcrumbs = array_merge($this->breadcrumbs, array('Редактирование категории "' . $model->title . '"')); $possibleParents = $model->getPossibleParents(); if (!empty($_POST) && array_key_exists('ShopCategories', $_POST)) { $this->performAjaxValidation($model); $model->attributes = $_POST['ShopCategories']; //var_dump($model->attributes);die; if ($model->validate()) { if ($model->save()) { Yii::app()->user->setFlash('success', 'Категория "' . $model->title . '" успешно отредактирована'); Yii::app()->request->redirect($this->createUrl('index')); } } } //var_dump($possibleParents);die; $this->render('edit', array('model' => $model, 'possibleParents' => $possibleParents)); }
/** * Предметы в категории * * @param string $category_link * @throws CHttpException */ public function actionCategory($category_link) { $criteria = new CDbCriteria(array('condition' => 'link = :link AND gs_id = :gs_id', 'params' => array('link' => $category_link, 'gs_id' => user()->getGsId()), 'scopes' => array('opened'))); $categoryModel = ShopCategories::model()->find($criteria); if (!$categoryModel) { throw new CHttpException(404, Yii::t('main', 'Нет данных.')); } // Наборы и предметы в наборах $dataProvider = new CActiveDataProvider('ShopItemsPacks', array('criteria' => new CDbCriteria(array('condition' => 'category_id = :category_id', 'params' => array('category_id' => $categoryModel->getPrimaryKey()), 'scopes' => array('opened'), 'order' => 't.sort', 'with' => array('items' => array('scopes' => array('opened'), 'order' => 'items.sort', 'with' => array('itemInfo'))))), 'pagination' => array('pageVar' => 'page', 'pageSize' => 5))); $this->render('//cabinet/shop/category', array('categories' => $this->getCategories(), 'categoryModel' => $categoryModel, 'dataProvider' => $dataProvider)); }
public function actionCategory($category) { //Ищем категорию по переданному пути $category = ShopCategories::model()->findByPath($category); if (!$category) { throw new CHttpException(404, Yii::t('app', 'Категория не найдена')); } $this->breadcrumbs = array_merge($this->breadcrumbs, $category->breadcrumbs); $this->pageTitle = $category->title; $this->pageDescription = $category->meta_description; $this->pageKeywords = $category->meta_keywords; $criteria = new CDbCriteria(); $this->render('category', array('category' => $category)); }
public function loadShopCategoriesModel($id) { $model = ShopCategories::model()->findByPk($id); if (!$model) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }