Exemple #1
0
 public function run()
 {
     //$comments = Comment::find()->where(['status' => Comment::STATUS_ACTIVE])->orderBy(['create_time' => SORT_DESC])->limit($this->maxComments)->all();
     $portlet = CmsCatalog::getRootCatalogSub2($this->id, CmsCatalog::find()->all());
     $rootCatalog = CmsCatalog::findOne(['id' => CmsCatalog::getRootCatalogId($this->id, CmsCatalog::find()->asArray()->all())]);
     $portletTitle = $rootCatalog ? $rootCatalog->title : '';
     if (!($portlet && $portletTitle)) {
         return;
     }
     return $this->render('sideMenu', ['title' => $portletTitle, 'portlet' => $portlet]);
 }
Exemple #2
-1
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         //menu
         $id = Yii::$app->request->get('id');
         $rootId = $id ? CmsCatalog::getRootCatalogId($id, CmsCatalog::find()->asArray()->all()) : 0;
         $allCatalog = CmsCatalog::find()->where(['status' => Status::STATUS_ACTIVE, 'is_nav' => CmsCatalog::IS_NAV_YES])->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_ASC])->all();
         foreach ($allCatalog as $catalog) {
             $item = ['label' => $catalog->title, 'active' => $catalog->id == $rootId];
             if ($catalog->redirect_url) {
                 // redirect to other site
                 $item['url'] = $catalog->redirect_url;
             } else {
                 $item['url'] = Yii::$app->getUrlManager()->createUrl(['/cms/default/' . $catalog->page_type . '/', 'id' => $catalog->id, 'surname' => $catalog->surname]);
             }
             if (!empty($item)) {
                 array_push($this->mainMenu, $item);
             }
         }
         Yii::$app->params['mainMenu'] = $this->mainMenu;
         return true;
         // or false if needed
     } else {
         return false;
     }
 }