public function actionShow() { $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; if (0 >= $id) { $this->redirect(Yii::$app->homeUrl); } $show = Show::findOne(['id' => $id]); $catalog = Catalog::findOne(['id' => $show->catalog_id]); $templatePage = $show->template ? $show->template : $catalog->template_show ? $catalog->template_show : 'show'; $portlet = Catalog::getCatalogSub2($id, Catalog::find()->all()); $portletTitle = Catalog::findOne(['id' => Catalog::getRootCatalogId($id, Catalog::find()->all())])->title; return $this->render($templatePage, ['catalog' => $catalog, 'show' => $show, 'portlet' => $portlet, 'portletTitle' => $portletTitle]); }
/** * Finds the Catalog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Catalog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Catalog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }