public function actionCatalog($id = null) { if ($id) { $categories = Category::findAll(['parent_id' => $id]); if ($categories === NULL) { throw new NotFoundHttpException("Категория {$id} не найдена"); } $oneLevelCategory = Category::findOne(['id' => $id]); $this->getView()->title = "Mexanika 74 - Каталог техники: " . $oneLevelCategory->name . " - " . \common\components\Htmlhelper::getMetaList($categories); return $this->render('catalog', ['categories' => $categories, 'oneLevelCategory' => $oneLevelCategory]); } else { //получить разделы у "Каталог техники" $partions = Category::getPartions(Category::TECHNICS_ID); //получить все категории, входящие в разделы $oneLvl = Category::getFirstLevel(Category::TECHNICS_ID); $this->getView()->title = "Mexanika 74 - Каталог техники: " . \common\components\Htmlhelper::getMetaList($partions); return $this->render('catalog', ['categories' => $oneLvl, 'parents' => $partions]); } }