| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- /**
- * Author: lf
- * Blog: https://blog.feehi.com
- * Email: job@feehi.com
- * Created at: 2016-04-02 22:48
- */
- namespace frontend\controllers;
- use Yii;
- use common\services\ArticleServiceInterface;
- use yii\web\NotFoundHttpException;
- class PageController extends \yii\web\Controller
- {
- /**
- * single page
- *
- * @param string $name
- * @return string
- * @throws yii\web\NotFoundHttpException
- * @throws yii\base\InvalidConfigException
- */
- public function actionView($name = '')
- {
- if ($name == '') {
- $name = Yii::$app->getRequest()->getPathInfo();
- }
- /** @var ArticleServiceInterface $service */
- $service = Yii::$app->get(ArticleServiceInterface::ServiceName);
- $model = $service->getArticleSubTitle($name);
- if (empty($model)) {
- throw new NotFoundHttpException('None page named ' . $name);
- }
- $template = "view";
- isset($model->category) && $model->category->template != "" && $template = $model->category->template;
- $model->template != "" && $template = $model->template;
- return $this->render($template, [
- 'model' => $model,
- 'singlePages' => $service->getSinglePages(),
- ]);
- }
- }
|