diff --git a/frontend/config/main.php b/frontend/config/main.php index fc991cc..3c2719f 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -3,53 +3,62 @@ use artbox\core\components\SeoUrlManager; $params = array_merge( - require(__DIR__ . '/../../common/config/params.php'), - require(__DIR__ . '/../../common/config/params-local.php'), - require(__DIR__ . '/params.php'), - require(__DIR__ . '/params-local.php') -); - -return [ - 'id' => 'app-frontend', - 'homeUrl' => '/', - 'basePath' => dirname(__DIR__), - 'bootstrap' => ['log'], - 'controllerNamespace' => 'frontend\controllers', - 'components' => [ - 'request' => [ - 'class' => LanguageRequest::className(), - 'csrfParam' => '_csrf-frontend', - 'baseUrl' => '', - ], - 'user' => [ - 'identityClass' => 'common\models\User', - 'enableAutoLogin' => true, - 'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true], - ], - 'session' => [ - // this is the name of the session cookie used for login on the frontend - 'name' => 'advanced-frontend', - ], - 'log' => [ - 'traceLevel' => YII_DEBUG ? 3 : 0, - 'targets' => [ - [ - 'class' => 'yii\log\FileTarget', - 'levels' => ['error', 'warning'], + require( __DIR__ . '/../../common/config/params.php' ), + require( __DIR__ . '/../../common/config/params-local.php' ), + require( __DIR__ . '/params.php' ), + require( __DIR__ . '/params-local.php' ) + ); + + return [ + 'id' => 'app-frontend', + 'homeUrl' => '/', + 'basePath' => dirname(__DIR__), + 'bootstrap' => [ 'log' ], + 'controllerNamespace' => 'frontend\controllers', + 'components' => [ + 'request' => [ + 'class' => LanguageRequest::className(), + 'csrfParam' => '_csrf-frontend', + 'baseUrl' => '', + ], + 'user' => [ + 'identityClass' => 'common\models\User', + 'enableAutoLogin' => true, + 'identityCookie' => [ + 'name' => '_identity-frontend', + 'httpOnly' => true, ], ], - ], - 'errorHandler' => [ - 'errorAction' => 'site/error', - ], - 'urlManager' => [ - 'class' => SeoUrlManager::className(), - 'enablePrettyUrl' => true, - 'showScriptName' => false, - 'rules' => [ - '\/robots.txt' => 'site/robots', + 'session' => [ + // this is the name of the session cookie used for login on the frontend + 'name' => 'advanced-frontend', + ], + 'log' => [ + 'traceLevel' => YII_DEBUG ? 3 : 0, + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => [ + 'error', + 'warning', + ], + ], + ], + ], + 'errorHandler' => [ + 'errorAction' => 'site/error', + ], + 'urlManager' => [ + 'class' => SeoUrlManager::className(), + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'processRoutes' => [ + 'page/view', + ], + 'rules' => [ + '\/robots.txt' => 'site/robots', + ], ], ], - ], - 'params' => $params, -]; + 'params' => $params, + ]; diff --git a/frontend/controllers/PageController.php b/frontend/controllers/PageController.php index 5870403..9d15262 100755 --- a/frontend/controllers/PageController.php +++ b/frontend/controllers/PageController.php @@ -1,12 +1,12 @@ findModel($id); - + /** * @var SeoComponent $seo */ $seo = Yii::$app->get('seo'); $seo->setModel($model->lang); - + + if (strpos($model->lang->body, '[[gallery]]')) { + $splited = explode('[[gallery]]', $model->lang->body); + $body = array_shift($splited); + $lefts = implode('', $splited); + } else { + $body = $model->lang->body; + $lefts = null; + } + $pages = Page::find() ->with('lang') ->where( @@ -38,18 +47,22 @@ return $this->render( 'view', [ - 'model' => $model, - 'pages' => $pages, + 'model' => $model, + 'pages' => $pages, + 'body' => $body, + 'lefts' => $lefts, 'images' => $model->getImages(), ] ); } - + protected function findModel($id) { /** - * @var Page $model + * @var Page $model + * @var SeoComponent $seo */ + $seo = \Yii::$app->get('seo'); $model = Page::find() ->where( [ @@ -58,9 +71,9 @@ ) ->with('lang') ->one(); - - if (!empty( $model )) { - if ($model->lang->alias_id !== Yii::$app->seo->aliasId) { + + if (!empty($model)) { + if ($model->lang->alias_id !== $seo->aliasId) { throw new NotFoundHttpException('Wrong language'); } return $model; diff --git a/frontend/views/page/view.php b/frontend/views/page/view.php index beb9451..fe494dd 100755 --- a/frontend/views/page/view.php +++ b/frontend/views/page/view.php @@ -10,7 +10,9 @@ * @var Page $model * @var Page[] $pages * @var SeoComponent $seo - * @var Image[] $images + * @var Image[] $images + * @var string $lefts + * @var string $body */ $seo = \Yii::$app->get('seo'); $this->params[ 'breadcrumbs' ][] = $seo->title; @@ -23,31 +25,37 @@ -