Commit 442daa2fd4686223268885266e0c91c8e533ac81
1 parent
bfb4edc1
img from gallery in static page
Showing
4 changed files
with
45 additions
and
6 deletions
Show diff stats
common/config/main.php
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
6 | 6 | 'modules' => [ |
7 | 7 | 'imagemanager' => [ |
8 | - 'class' => 'noam148\imagemanager\Module', | |
8 | + 'class' => 'artbox\core\components\imagemanager\Module', | |
9 | 9 | 'canUploadImage' => true, |
10 | 10 | 'canRemoveImage' => function () { |
11 | 11 | return true; | ... | ... |
frontend/controllers/PageController.php
... | ... | @@ -27,6 +27,15 @@ |
27 | 27 | $seo = Yii::$app->get('seo'); |
28 | 28 | $seo->setModel($model->lang); |
29 | 29 | |
30 | + if (strpos($model->lang->body, '[[gallery]]')) { | |
31 | + $splited = explode('[[gallery]]', $model->lang->body); | |
32 | + $body = array_shift($splited); | |
33 | + $lefts = implode('', $splited); | |
34 | + } else { | |
35 | + $body = $model->lang->body; | |
36 | + $lefts = null; | |
37 | + } | |
38 | + | |
30 | 39 | $pages = Page::find() |
31 | 40 | ->with('lang') |
32 | 41 | ->where( |
... | ... | @@ -41,8 +50,11 @@ |
41 | 50 | return $this->render( |
42 | 51 | 'view', |
43 | 52 | [ |
44 | - 'model' => $model, | |
45 | - 'pages' => $pages, | |
53 | + 'model' => $model, | |
54 | + 'pages' => $pages, | |
55 | + 'images' => $model->getImages(), | |
56 | + 'body' => $body, | |
57 | + 'lefts' => $lefts, | |
46 | 58 | ] |
47 | 59 | ); |
48 | 60 | } | ... | ... |
frontend/views/page/view.php
... | ... | @@ -3,12 +3,16 @@ |
3 | 3 | use artbox\core\models\Page; |
4 | 4 | use yii\helpers\Html; |
5 | 5 | use yii\web\View; |
6 | + use artbox\core\models\Image; | |
6 | 7 | |
7 | 8 | /** |
8 | 9 | * @var View $this |
9 | 10 | * @var Page $model |
10 | 11 | * @var Page[] $pages |
11 | 12 | * @var SeoComponent $seo |
13 | + * @var Image[] $images | |
14 | + * @var string $body | |
15 | + * @var string|null $lefts | |
12 | 16 | */ |
13 | 17 | $seo = \Yii::$app->get('seo'); |
14 | 18 | $this->params[ 'breadcrumbs' ][] = $seo->title; |
... | ... | @@ -27,12 +31,35 @@ |
27 | 31 | <section> |
28 | 32 | <div id="text-page"> |
29 | 33 | <div class="lead"> |
30 | - | |
31 | - <?= $model->lang->body ?> | |
32 | - | |
34 | + <?= $body ?> | |
33 | 35 | </div> |
34 | 36 | </div> |
35 | 37 | </section> |
38 | + | |
39 | + <?php if (!empty($images) && !empty($lefts)) { ?> | |
40 | + <section> | |
41 | + <div class="project owl-carousel"> | |
42 | + | |
43 | + <?php foreach ($images as $image) { ?> | |
44 | + <div class="item"> | |
45 | + <img class="img-responsive" src="<?= $image->getUrl() ?>" alt=""> | |
46 | + </div> | |
47 | + <?php } ?> | |
48 | + | |
49 | + </div> | |
50 | + <!-- /.project owl-slider --> | |
51 | + </section> | |
52 | + <?php } ?> | |
53 | + | |
54 | + <?php if (!empty($lefts)) { ?> | |
55 | + <section> | |
56 | + <div id="text-page"> | |
57 | + <div class="lead"> | |
58 | + <?= $lefts ?> | |
59 | + </div> | |
60 | + </div> | |
61 | + </section> | |
62 | + <?php } ?> | |
36 | 63 | |
37 | 64 | </div> |
38 | 65 | <!-- /.col-md-9 --> | ... | ... |