Exemplo n.º 1
0
 public function actionDelete($id)
 {
     if ($model = Page::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/page', 'Page deleted'));
 }
Exemplo n.º 2
0
 public function actionPage($slug)
 {
     $menuItems = [];
     foreach (Page::find()->all() as $model) {
         $menuItems[] = ['label' => $model->title, 'url' => ['site/page', 'slug' => $model->slug]];
     }
     $page = Page::findOne(['slug' => $slug]);
     if (!$page) {
         throw new NotFoundHttpException();
     }
     return $this->render('page', ['page' => $page, 'menuItems' => $menuItems]);
 }