Commit 63296d615b63c239f1ac1b1fb9897b40ef9a990c
1 parent
540d16cd
-Added gallery
Showing
3 changed files
with
109 additions
and
78 deletions
Show diff stats
frontend/config/main.php
@@ -3,53 +3,62 @@ | @@ -3,53 +3,62 @@ | ||
3 | use artbox\core\components\SeoUrlManager; | 3 | use artbox\core\components\SeoUrlManager; |
4 | 4 | ||
5 | $params = array_merge( | 5 | $params = array_merge( |
6 | - require(__DIR__ . '/../../common/config/params.php'), | ||
7 | - require(__DIR__ . '/../../common/config/params-local.php'), | ||
8 | - require(__DIR__ . '/params.php'), | ||
9 | - require(__DIR__ . '/params-local.php') | ||
10 | -); | ||
11 | - | ||
12 | -return [ | ||
13 | - 'id' => 'app-frontend', | ||
14 | - 'homeUrl' => '/', | ||
15 | - 'basePath' => dirname(__DIR__), | ||
16 | - 'bootstrap' => ['log'], | ||
17 | - 'controllerNamespace' => 'frontend\controllers', | ||
18 | - 'components' => [ | ||
19 | - 'request' => [ | ||
20 | - 'class' => LanguageRequest::className(), | ||
21 | - 'csrfParam' => '_csrf-frontend', | ||
22 | - 'baseUrl' => '', | ||
23 | - ], | ||
24 | - 'user' => [ | ||
25 | - 'identityClass' => 'common\models\User', | ||
26 | - 'enableAutoLogin' => true, | ||
27 | - 'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true], | ||
28 | - ], | ||
29 | - 'session' => [ | ||
30 | - // this is the name of the session cookie used for login on the frontend | ||
31 | - 'name' => 'advanced-frontend', | ||
32 | - ], | ||
33 | - 'log' => [ | ||
34 | - 'traceLevel' => YII_DEBUG ? 3 : 0, | ||
35 | - 'targets' => [ | ||
36 | - [ | ||
37 | - 'class' => 'yii\log\FileTarget', | ||
38 | - 'levels' => ['error', 'warning'], | 6 | + require( __DIR__ . '/../../common/config/params.php' ), |
7 | + require( __DIR__ . '/../../common/config/params-local.php' ), | ||
8 | + require( __DIR__ . '/params.php' ), | ||
9 | + require( __DIR__ . '/params-local.php' ) | ||
10 | + ); | ||
11 | + | ||
12 | + return [ | ||
13 | + 'id' => 'app-frontend', | ||
14 | + 'homeUrl' => '/', | ||
15 | + 'basePath' => dirname(__DIR__), | ||
16 | + 'bootstrap' => [ 'log' ], | ||
17 | + 'controllerNamespace' => 'frontend\controllers', | ||
18 | + 'components' => [ | ||
19 | + 'request' => [ | ||
20 | + 'class' => LanguageRequest::className(), | ||
21 | + 'csrfParam' => '_csrf-frontend', | ||
22 | + 'baseUrl' => '', | ||
23 | + ], | ||
24 | + 'user' => [ | ||
25 | + 'identityClass' => 'common\models\User', | ||
26 | + 'enableAutoLogin' => true, | ||
27 | + 'identityCookie' => [ | ||
28 | + 'name' => '_identity-frontend', | ||
29 | + 'httpOnly' => true, | ||
39 | ], | 30 | ], |
40 | ], | 31 | ], |
41 | - ], | ||
42 | - 'errorHandler' => [ | ||
43 | - 'errorAction' => 'site/error', | ||
44 | - ], | ||
45 | - 'urlManager' => [ | ||
46 | - 'class' => SeoUrlManager::className(), | ||
47 | - 'enablePrettyUrl' => true, | ||
48 | - 'showScriptName' => false, | ||
49 | - 'rules' => [ | ||
50 | - '\/robots.txt' => 'site/robots', | 32 | + 'session' => [ |
33 | + // this is the name of the session cookie used for login on the frontend | ||
34 | + 'name' => 'advanced-frontend', | ||
35 | + ], | ||
36 | + 'log' => [ | ||
37 | + 'traceLevel' => YII_DEBUG ? 3 : 0, | ||
38 | + 'targets' => [ | ||
39 | + [ | ||
40 | + 'class' => 'yii\log\FileTarget', | ||
41 | + 'levels' => [ | ||
42 | + 'error', | ||
43 | + 'warning', | ||
44 | + ], | ||
45 | + ], | ||
46 | + ], | ||
47 | + ], | ||
48 | + 'errorHandler' => [ | ||
49 | + 'errorAction' => 'site/error', | ||
50 | + ], | ||
51 | + 'urlManager' => [ | ||
52 | + 'class' => SeoUrlManager::className(), | ||
53 | + 'enablePrettyUrl' => true, | ||
54 | + 'showScriptName' => false, | ||
55 | + 'processRoutes' => [ | ||
56 | + 'page/view', | ||
57 | + ], | ||
58 | + 'rules' => [ | ||
59 | + '\/robots.txt' => 'site/robots', | ||
60 | + ], | ||
51 | ], | 61 | ], |
52 | ], | 62 | ], |
53 | - ], | ||
54 | - 'params' => $params, | ||
55 | -]; | 63 | + 'params' => $params, |
64 | + ]; |
frontend/controllers/PageController.php
1 | <?php | 1 | <?php |
2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
3 | - | 3 | + |
4 | use artbox\core\components\SeoComponent; | 4 | use artbox\core\components\SeoComponent; |
5 | use artbox\core\models\Page; | 5 | use artbox\core\models\Page; |
6 | use yii\web\Controller; | 6 | use yii\web\Controller; |
7 | use yii\web\NotFoundHttpException; | 7 | use yii\web\NotFoundHttpException; |
8 | use Yii; | 8 | use Yii; |
9 | - | 9 | + |
10 | /** | 10 | /** |
11 | * Class PageController | 11 | * Class PageController |
12 | * | 12 | * |
@@ -17,13 +17,22 @@ | @@ -17,13 +17,22 @@ | ||
17 | public function actionView($id) | 17 | public function actionView($id) |
18 | { | 18 | { |
19 | $model = $this->findModel($id); | 19 | $model = $this->findModel($id); |
20 | - | 20 | + |
21 | /** | 21 | /** |
22 | * @var SeoComponent $seo | 22 | * @var SeoComponent $seo |
23 | */ | 23 | */ |
24 | $seo = Yii::$app->get('seo'); | 24 | $seo = Yii::$app->get('seo'); |
25 | $seo->setModel($model->lang); | 25 | $seo->setModel($model->lang); |
26 | - | 26 | + |
27 | + if (strpos($model->lang->body, '[[gallery]]')) { | ||
28 | + $splited = explode('[[gallery]]', $model->lang->body); | ||
29 | + $body = array_shift($splited); | ||
30 | + $lefts = implode('', $splited); | ||
31 | + } else { | ||
32 | + $body = $model->lang->body; | ||
33 | + $lefts = null; | ||
34 | + } | ||
35 | + | ||
27 | $pages = Page::find() | 36 | $pages = Page::find() |
28 | ->with('lang') | 37 | ->with('lang') |
29 | ->where( | 38 | ->where( |
@@ -38,18 +47,22 @@ | @@ -38,18 +47,22 @@ | ||
38 | return $this->render( | 47 | return $this->render( |
39 | 'view', | 48 | 'view', |
40 | [ | 49 | [ |
41 | - 'model' => $model, | ||
42 | - 'pages' => $pages, | 50 | + 'model' => $model, |
51 | + 'pages' => $pages, | ||
52 | + 'body' => $body, | ||
53 | + 'lefts' => $lefts, | ||
43 | 'images' => $model->getImages(), | 54 | 'images' => $model->getImages(), |
44 | ] | 55 | ] |
45 | ); | 56 | ); |
46 | } | 57 | } |
47 | - | 58 | + |
48 | protected function findModel($id) | 59 | protected function findModel($id) |
49 | { | 60 | { |
50 | /** | 61 | /** |
51 | - * @var Page $model | 62 | + * @var Page $model |
63 | + * @var SeoComponent $seo | ||
52 | */ | 64 | */ |
65 | + $seo = \Yii::$app->get('seo'); | ||
53 | $model = Page::find() | 66 | $model = Page::find() |
54 | ->where( | 67 | ->where( |
55 | [ | 68 | [ |
@@ -58,9 +71,9 @@ | @@ -58,9 +71,9 @@ | ||
58 | ) | 71 | ) |
59 | ->with('lang') | 72 | ->with('lang') |
60 | ->one(); | 73 | ->one(); |
61 | - | ||
62 | - if (!empty( $model )) { | ||
63 | - if ($model->lang->alias_id !== Yii::$app->seo->aliasId) { | 74 | + |
75 | + if (!empty($model)) { | ||
76 | + if ($model->lang->alias_id !== $seo->aliasId) { | ||
64 | throw new NotFoundHttpException('Wrong language'); | 77 | throw new NotFoundHttpException('Wrong language'); |
65 | } | 78 | } |
66 | return $model; | 79 | return $model; |
frontend/views/page/view.php
@@ -10,7 +10,9 @@ | @@ -10,7 +10,9 @@ | ||
10 | * @var Page $model | 10 | * @var Page $model |
11 | * @var Page[] $pages | 11 | * @var Page[] $pages |
12 | * @var SeoComponent $seo | 12 | * @var SeoComponent $seo |
13 | - * @var Image[] $images | 13 | + * @var Image[] $images |
14 | + * @var string $lefts | ||
15 | + * @var string $body | ||
14 | */ | 16 | */ |
15 | $seo = \Yii::$app->get('seo'); | 17 | $seo = \Yii::$app->get('seo'); |
16 | $this->params[ 'breadcrumbs' ][] = $seo->title; | 18 | $this->params[ 'breadcrumbs' ][] = $seo->title; |
@@ -23,31 +25,37 @@ | @@ -23,31 +25,37 @@ | ||
23 | 25 | ||
24 | <!-- *** LEFT COLUMN *** | 26 | <!-- *** LEFT COLUMN *** |
25 | _________________________________________________________ --> | 27 | _________________________________________________________ --> |
26 | - | ||
27 | <div class="col-md-9 clearfix"> | 28 | <div class="col-md-9 clearfix"> |
28 | - | ||
29 | - <?php if (!empty($images)) { ?> | ||
30 | - <section> | ||
31 | - <div class="project owl-carousel"> | ||
32 | - | ||
33 | - <?php foreach ($images as $image) { ?> | ||
34 | - <div class="item"> | ||
35 | - <img class="img-responsive" src="<?=$image->getUrl()?>" alt=""> | ||
36 | - </div> | ||
37 | - <?php } ?> | ||
38 | - | ||
39 | - </div> | ||
40 | - <!-- /.project owl-slider --> | ||
41 | - </section> | ||
42 | - <?php } ?> | ||
43 | - | ||
44 | <section> | 29 | <section> |
45 | <div id="text-page"> | 30 | <div id="text-page"> |
46 | 31 | ||
47 | - <?= $model->lang->body ?> | 32 | + <?= $body ?> |
48 | 33 | ||
49 | </div> | 34 | </div> |
50 | </section> | 35 | </section> |
36 | + | ||
37 | + <?php if (!empty($images) && !empty($lefts)) { ?> | ||
38 | + <section> | ||
39 | + <div class="project owl-carousel"> | ||
40 | + | ||
41 | + <?php foreach ($images as $image) { ?> | ||
42 | + <div class="item"> | ||
43 | + <img class="img-responsive" src="<?= $image->getUrl() ?>" alt=""> | ||
44 | + </div> | ||
45 | + <?php } ?> | ||
46 | + | ||
47 | + </div> | ||
48 | + <!-- /.project owl-slider --> | ||
49 | + </section> | ||
50 | + | ||
51 | + <section> | ||
52 | + <div id="text-page"> | ||
53 | + | ||
54 | + <?= $lefts ?> | ||
55 | + | ||
56 | + </div> | ||
57 | + </section> | ||
58 | + <?php } ?> | ||
51 | 59 | ||
52 | </div> | 60 | </div> |
53 | <!-- /.col-md-9 --> | 61 | <!-- /.col-md-9 --> |
@@ -88,13 +96,14 @@ _________________________________________________________ --> | @@ -88,13 +96,14 @@ _________________________________________________________ --> | ||
88 | </div> | 96 | </div> |
89 | 97 | ||
90 | <!-- *** PAGES MENU END *** --> | 98 | <!-- *** PAGES MENU END *** --> |
91 | - | ||
92 | - | 99 | + |
100 | + <?php /* | ||
93 | <div class="banner"> | 101 | <div class="banner"> |
94 | <a href="shop-category.html"> | 102 | <a href="shop-category.html"> |
95 | <img src="/img/banner.jpg" alt="sales 2014" class="img-responsive"> | 103 | <img src="/img/banner.jpg" alt="sales 2014" class="img-responsive"> |
96 | </a> | 104 | </a> |
97 | </div> | 105 | </div> |
106 | + */ ?> | ||
98 | <!-- /.banner --> | 107 | <!-- /.banner --> |
99 | </div> | 108 | </div> |
100 | <!-- /.col-md-3 --> | 109 | <!-- /.col-md-3 --> |