Commit 442daa2fd4686223268885266e0c91c8e533ac81

Authored by Timur Kastemirov
1 parent bfb4edc1

img from gallery in static page

common/config/main.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 5 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
6 'modules' => [ 6 'modules' => [
7 'imagemanager' => [ 7 'imagemanager' => [
8 - 'class' => 'noam148\imagemanager\Module', 8 + 'class' => 'artbox\core\components\imagemanager\Module',
9 'canUploadImage' => true, 9 'canUploadImage' => true,
10 'canRemoveImage' => function () { 10 'canRemoveImage' => function () {
11 return true; 11 return true;
common/images/5_ifZKvN_QGrY6VnuFtjfPa_-Va_7x6hd3.png 100644 → 100755

20.9 KB | W: | H:

20.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
frontend/controllers/PageController.php
@@ -27,6 +27,15 @@ @@ -27,6 +27,15 @@
27 $seo = Yii::$app->get('seo'); 27 $seo = Yii::$app->get('seo');
28 $seo->setModel($model->lang); 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 $pages = Page::find() 39 $pages = Page::find()
31 ->with('lang') 40 ->with('lang')
32 ->where( 41 ->where(
@@ -41,8 +50,11 @@ @@ -41,8 +50,11 @@
41 return $this->render( 50 return $this->render(
42 'view', 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,12 +3,16 @@
3 use artbox\core\models\Page; 3 use artbox\core\models\Page;
4 use yii\helpers\Html; 4 use yii\helpers\Html;
5 use yii\web\View; 5 use yii\web\View;
  6 + use artbox\core\models\Image;
6 7
7 /** 8 /**
8 * @var View $this 9 * @var View $this
9 * @var Page $model 10 * @var Page $model
10 * @var Page[] $pages 11 * @var Page[] $pages
11 * @var SeoComponent $seo 12 * @var SeoComponent $seo
  13 + * @var Image[] $images
  14 + * @var string $body
  15 + * @var string|null $lefts
12 */ 16 */
13 $seo = \Yii::$app->get('seo'); 17 $seo = \Yii::$app->get('seo');
14 $this->params[ 'breadcrumbs' ][] = $seo->title; 18 $this->params[ 'breadcrumbs' ][] = $seo->title;
@@ -27,12 +31,35 @@ @@ -27,12 +31,35 @@
27 <section> 31 <section>
28 <div id="text-page"> 32 <div id="text-page">
29 <div class="lead"> 33 <div class="lead">
30 -  
31 - <?= $model->lang->body ?>  
32 - 34 + <?= $body ?>
33 </div> 35 </div>
34 </div> 36 </div>
35 </section> 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 </div> 64 </div>
38 <!-- /.col-md-9 --> 65 <!-- /.col-md-9 -->