Commit 0b098d0a2505bbff7be40868d1fb171bbbe31602

Authored by Anastasia
1 parent 69bfcdd3

add speaker to index

frontend/assets/SliderAsset.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 30.08.18
  6 + * Time: 12:50
  7 + */
  8 +
  9 + namespace frontend\assets;
  10 +
  11 + use yii\web\AssetBundle;
  12 +
  13 + class SliderAsset extends AssetBundle
  14 + {
  15 + public $basePath = '@webroot';
  16 + public $baseUrl = '@web';
  17 + public $css = [
  18 + 'css/style.css',
  19 + ];
  20 + public $js = [
  21 + 'js/sliders.js',
  22 + 'js/new-owl/owl.carousel.js',
  23 + 'js/new-owl/owl.autoplay.js',
  24 + 'js/new-owl/owl.navigation.js',
  25 + 'js/new-owl/owl.support.js'
  26 + ];
  27 + public $depends = [
  28 + 'frontend\assets\AppAsset',
  29 +
  30 + ];
  31 + }
0 \ No newline at end of file 32 \ No newline at end of file
frontend/controllers/SiteController.php
@@ -2,9 +2,8 @@ @@ -2,9 +2,8 @@
2 namespace frontend\controllers; 2 namespace frontend\controllers;
3 3
4 use artbox\core\models\Feedback; 4 use artbox\core\models\Feedback;
5 - use common\models\blog\Article;  
6 use common\models\Settings; 5 use common\models\Settings;
7 - use common\models\slider\Slide; 6 + use common\models\speaker\Speaker;
8 use Yii; 7 use Yii;
9 use yii\filters\VerbFilter; 8 use yii\filters\VerbFilter;
10 use yii\swiftmailer\Mailer; 9 use yii\swiftmailer\Mailer;
@@ -51,16 +50,9 @@ @@ -51,16 +50,9 @@
51 */ 50 */
52 public function actionIndex() 51 public function actionIndex()
53 { 52 {
54 - $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all();  
55 - $articles = Article::find()  
56 - ->with('language')  
57 - ->where([ 'status' => true ])  
58 - ->orderBy('sort DESC')  
59 - ->limit(4)  
60 - ->all(); 53 + $speakers = Speaker::find()->with(['language', 'image'])->where(['status' => true])->orderBy('sort')->all();
61 return $this->render('index', [ 54 return $this->render('index', [
62 - 'slides' => $slides,  
63 - 'articles' => $articles 55 + 'speakers' => $speakers
64 ]); 56 ]);
65 } 57 }
66 58
frontend/views/site/index.php
1 <?php 1 <?php
2 2
3 /* @var $this yii\web\View 3 /* @var $this yii\web\View
4 - * @var \common\models\slider\Slide[] $slides;  
5 - * @var \common\models\blog\Article[] $articles 4 + * @var \common\models\speaker\Speaker[] $speakers
6 */ 5 */
7 6
8 use artbox\core\helpers\ImageHelper; 7 use artbox\core\helpers\ImageHelper;
9 use artbox\core\helpers\Url; 8 use artbox\core\helpers\Url;
  9 + use frontend\assets\SliderAsset;
10 10
  11 + SliderAsset::register($this);
11 ?> 12 ?>
12 13
13 <section class="section-first-home"> 14 <section class="section-first-home">
@@ -44,84 +45,34 @@ @@ -44,84 +45,34 @@
44 </div> 45 </div>
45 </div> 46 </div>
46 </section> 47 </section>
47 - 48 +<?php if (!empty($speakers)){?>
48 <section class="section-speakers"> 49 <section class="section-speakers">
49 <div class="container"> 50 <div class="container">
50 <div class="row"> 51 <div class="row">
51 - <div class="col-xs-12"><div class="speakers-title">Спікери</div></div> 52 + <div class="col-xs-12"><div class="speakers-title"><?=\Yii::t('app', 'Спікери')?></div></div>
52 </div> 53 </div>
53 54
54 <div class="row"> 55 <div class="row">
55 <div class="col-xs-12 col-sm-12"> 56 <div class="col-xs-12 col-sm-12">
56 <div class="slider-home sliders row owl-carousel"> 57 <div class="slider-home sliders row owl-carousel">
  58 + <?php foreach ($speakers as $speaker){?>
57 <div class="col-xs-12 col-sm-4 col-md-3 items-home-col"> 59 <div class="col-xs-12 col-sm-4 col-md-3 items-home-col">
58 <div class="items-home"> 60 <div class="items-home">
59 <div class="items-home-img"> 61 <div class="items-home-img">
60 <!--263x210--> 62 <!--263x210-->
61 - <a href="#"><img src="images/speakers/speakers-1.jpg" alt=""></a>  
62 - </div>  
63 - <div class="items-home-name">Віце-прем'єр-міністр</div>  
64 - <div class="items-home-job">Віце-прем'єр-міністр</div>  
65 - <div class="items-home-country-wr">  
66 - <div class="items-home-country"><a href="#">Україна</a></div>  
67 - </div>  
68 - </div>  
69 - </div>  
70 -  
71 - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col">  
72 - <div class="items-home">  
73 - <div class="items-home-img">  
74 - <a href="#"><img src="images/speakers/speakers-2.jpg" alt=""></a>  
75 - </div>  
76 - <div class="items-home-name">Ігор Насалик </div>  
77 - <div class="items-home-job">Міністр енергетики та вугільної промисловості</div>  
78 - <div class="items-home-country-wr">  
79 - <div class="items-home-country"><a href="#">Україна</a></div>  
80 - </div>  
81 - </div>  
82 - </div>  
83 -  
84 - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col">  
85 - <div class="items-home">  
86 - <div class="items-home-img">  
87 - <a href="#"><img src="images/speakers/speakers-3.jpg" alt=""></a> 63 + <a href="#"><img src="<?=ImageHelper::set($speaker->image->getPath())->cropResize(263, 210)->render()?>" alt=""></a>
88 </div> 64 </div>
89 - <div class="items-home-name">Наталія Бойко</div>  
90 - <div class="items-home-job">Заступник міністра енергетики і вугільної промисловості</div> 65 + <div class="items-home-name"><?=$speaker->language->name?></div>
  66 + <div class="items-home-job"><?=$speaker->language->position?></div>
91 <div class="items-home-country-wr"> 67 <div class="items-home-country-wr">
92 - <div class="items-home-country"><a href="#">Україна</a></div> 68 + <div class="items-home-country"><a href="#"><?=$speaker->language->organization?></a></div>
93 </div> 69 </div>
94 </div> 70 </div>
95 </div> 71 </div>
96 -  
97 - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col">  
98 - <div class="items-home">  
99 - <div class="items-home-img">  
100 - <a href="#"><img src="images/speakers/speakers-4.jpg" alt=""></a>  
101 - </div>  
102 - <div class="items-home-name">Лі Юн</div>  
103 - <div class="items-home-job">Генеральний директор</div>  
104 - <div class="items-home-country-wr">  
105 - <div class="items-home-country"><a href="#">Організація Об'єднаних Націй з промислового розвитку (ЮНІДО)</a></div>  
106 - </div>  
107 - </div>  
108 - </div>  
109 -  
110 - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col">  
111 - <div class="items-home">  
112 - <div class="items-home-img">  
113 - <a href="#"><img src="images/speakers/speakers-4.jpg" alt=""></a>  
114 - </div>  
115 - <div class="items-home-name">Лі Юн</div>  
116 - <div class="items-home-job">Генеральний директор</div>  
117 - <div class="items-home-country-wr">  
118 - <div class="items-home-country"><a href="#">Організація Об'єднаних Націй з промислового розвитку (ЮНІДО)</a></div>  
119 - </div>  
120 - </div>  
121 - </div>  
122 - 72 + <?php } ?>
123 </div> 73 </div>
124 </div> 74 </div>
125 </div> 75 </div>
126 </div> 76 </div>
127 -</section>  
128 \ No newline at end of file 77 \ No newline at end of file
  78 +</section>
  79 +<?php } ?>
129 \ No newline at end of file 80 \ No newline at end of file