public function loadModel($id)
 {
     if (($model = PortfolioCategory::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
 public function actionCategory($path)
 {
     $category = PortfolioCategory::model()->published()->with(array('children' => array('scopes' => 'published', 'order' => 'children.sort ASC'), 'slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->findByPath($path);
     if (!$category) {
         throw new CHttpException(404);
     }
     $this->render('category', array('model' => $category));
 }
 protected function beforeAction($action)
 {
     $actions = array('index', 'create');
     if (in_array($action->id, $actions)) {
         $this->item_id = (int) Yii::app()->getRequest()->getParam('item_id');
         if (!$this->item_id) {
             throw new CHttpException(400, 'Не установлен ID категории');
         }
         if (($this->item = PortfolioCategory::model()->findByPk($this->item_id)) === null) {
             throw new CHttpException(404, 'Кталогия не найдена');
         }
     }
     return parent::beforeAction($action);
 }
Пример #4
0
<?php

$categories = CHtml::listData(PortfolioCategory::model()->findAll(['condition' => 't.parent_id IS NULL OR t.parent_id = 0', 'order' => 't.sort ASC']), 'id', 'title');
$this->widget('yupe\\widgets\\OGridView', array('id' => 'category-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'image', 'type' => 'raw', 'value' => '$data->image ? CHtml::image($data->getImageUrl(220, 150), $data->title)  : ""', 'filter' => false, 'sortable' => false, 'htmlOptions' => array('style' => 'width:220px')), array('name' => 'title', 'class' => 'yupe.widgets.columns.DLinkColumn', 'link' => '$data->getUrl()', 'indentSymbol' => '&ndash; ', 'indentSize' => 2, 'options' => array('target' => '_blank')), array('name' => 'path', 'type' => 'raw', 'sortable' => false, 'value' => '($data->alias == "index" && $data->parent_id == 0)? "/" :  $data->getUrl()'), array('name' => 'sort', 'class' => 'yupe.widgets.CustomEditableColumn', 'htmlOptions' => array('style' => 'width:80px'), 'editable' => array('placement' => 'right', 'success' => 'js: function(response, newValue) {
                    $.fn.yiiGridView.update("series-grid"); 
                }')), array('name' => 'status', 'type' => 'raw', 'value' => '$this->grid->returnBootstrapStatusHtml($data, "status", "Status", array("pencil", "ok-sign"))', 'filter' => $model->getStatusList(), 'htmlOptions' => array('style' => 'width: 80px;'), 'sortable' => false), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{images}{slides}{update}{delete}', 'buttons' => array('images' => array('icon' => 'picture', 'label' => 'Изображения', 'url' => 'array("/portfolio/imageBackend/index", "item_id" => $data->id)'), 'slides' => array('icon' => 'picture', 'label' => 'Слайды', 'url' => 'array("/slider/slideBackend/index", "type" => "PortfolioCategory",  "entity_id" => $data->id)')), 'htmlOptions' => array('style' => 'width: 80px; text-align: right;')))));
 public function run()
 {
     $categories = PortfolioCategory::model()->root()->published()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->findAll(array('order' => 't.sort ASC'));
     $this->render($this->view, array('models' => $categories, 'withTitle' => $this->withTitle));
 }