public function parseRequest($manager, $request) { $pathInfo = $request->getPathInfo(); if (preg_match('%^(\\w+)(/(\\w+))?' . $manager->suffix . '$%', $pathInfo, $matches)) { if (!isset($matches[3])) { if (method_exists('\\frontend\\controllers\\SiteController', 'action' . ucfirst($matches[1]))) { return ['site/' . $matches[1], []]; } return false; } switch ($matches[1]) { case 'page': $page = Pages::findOne(['slug' => $matches[3]]); if (!isset($page)) { return false; } return ['page/index', ['slug' => $matches[3]]]; break; case 'site': Yii::$app->response->redirect(array($matches[3] . '/'), 301); default: return false; } } return false; // this rule does not apply }
public function actionIndex() { $page = Pages::findOne(['uri' => \Yii::$app->request->get('uri'), 'status' => 10]); if (!$page) { throw new NotFoundHttpException('Сторінки, яку Ви шукаєте не існує.'); } return $this->render('index', ['page' => $page]); }
public function actionView($url) { $page = Pages::findOne(['url' => $url]); if ($page) { return $this->render('/pages/view', ['page' => $page]); } else { return $this->render('/pages/404', ['url' => $url]); } }
<?php use yii\helpers\Html; use common\models\Pages; use yii\helpers\Url; if ($result === false) { if (Yii::$app->options->get(2)->value != 'error') { $page = Pages::findOne(Yii::$app->options->get(2)->value); } else { throw new \yii\web\HttpException(203, 'Non-Authoritative Information.', 203); } } ?> <div class="col-md-12 banner-section" id="alertSection"> <!-- START "please register banner" --> <div class="row"> <div class="col-md-12 box"> </div> </div> </div> <!-- col end --> <!-- end .banner-section --> <?php if ($result !== false) { if (!isset(Yii::$app->user->identity->username)) { ?> <div class="col-md-12 banner-section"> <!-- START "please register banner" --> <div class="row"> <div class="col-md-12"> <?php foreach (Yii::$app->notifications->getAll() as $notify) { ?> <div class="alert alert-<?php
/** * Finds the Pages model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Pages the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Pages::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Pages model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Pages the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Pages::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('Сторінки, яку Ви шукаєте не існує.'); } }