Commit c8dead9418d7e26972dd48ab034c1cd21a5faadb
Merge remote-tracking branch 'origin/master'
Showing
9 changed files
with
812 additions
and
56 deletions
Show diff stats
frontend/controllers/BlogController.php
... | ... | @@ -3,8 +3,11 @@ |
3 | 3 | namespace frontend\controllers; |
4 | 4 | |
5 | 5 | use artbox\weblog\models\Article; |
6 | + use artbox\weblog\models\Category; | |
7 | + use artbox\weblog\models\Tag; | |
6 | 8 | use yii\data\ActiveDataProvider; |
7 | 9 | use yii\web\Controller; |
10 | + use yii\web\NotFoundHttpException; | |
8 | 11 | |
9 | 12 | /** |
10 | 13 | * Class BlogController |
... | ... | @@ -13,8 +16,15 @@ |
13 | 16 | */ |
14 | 17 | class BlogController extends Controller |
15 | 18 | { |
16 | - public function actionIndex() | |
19 | + public function actionIndex($q = '') | |
17 | 20 | { |
21 | + $tags = Tag::find() | |
22 | + ->with( | |
23 | + [ | |
24 | + 'lang', | |
25 | + ] | |
26 | + ) | |
27 | + ->all(); | |
18 | 28 | $dataProvider = new ActiveDataProvider( |
19 | 29 | [ |
20 | 30 | 'query' => Article::find() |
... | ... | @@ -22,6 +32,19 @@ |
22 | 32 | [ |
23 | 33 | 'created_at' => SORT_DESC, |
24 | 34 | ] |
35 | + ) | |
36 | + ->joinWith( | |
37 | + [ | |
38 | + 'lang', | |
39 | + 'categories.lang', | |
40 | + ] | |
41 | + ) | |
42 | + ->andFilterWhere( | |
43 | + [ | |
44 | + 'like', | |
45 | + 'blog_article_lang.title', | |
46 | + $q, | |
47 | + ] | |
25 | 48 | ), |
26 | 49 | 'pagination' => [ |
27 | 50 | 'pageSize' => 3, |
... | ... | @@ -32,8 +55,167 @@ |
32 | 55 | return $this->render( |
33 | 56 | 'index', |
34 | 57 | [ |
58 | + 'tags' => $tags, | |
35 | 59 | 'dataProvider' => $dataProvider, |
36 | 60 | ] |
37 | 61 | ); |
38 | 62 | } |
63 | + | |
64 | + public function actionArticle($id) | |
65 | + { | |
66 | + $model = $this->findModel($id); | |
67 | + | |
68 | + $tags = Tag::find() | |
69 | + ->with([ 'lang' ]) | |
70 | + ->all(); | |
71 | + | |
72 | + return $this->render( | |
73 | + 'view', | |
74 | + [ | |
75 | + 'tags' => $tags, | |
76 | + 'model' => $model, | |
77 | + ] | |
78 | + ); | |
79 | + } | |
80 | + | |
81 | + public function actionCategory($id) | |
82 | + { | |
83 | + $tags = Tag::find() | |
84 | + ->with( | |
85 | + [ | |
86 | + 'lang', | |
87 | + ] | |
88 | + ) | |
89 | + ->all(); | |
90 | + | |
91 | + /** | |
92 | + * @var Category $model | |
93 | + */ | |
94 | + $model = Category::find() | |
95 | + ->where( | |
96 | + [ | |
97 | + 'id' => $id, | |
98 | + ] | |
99 | + ) | |
100 | + ->with( | |
101 | + [ | |
102 | + 'articles', | |
103 | + ] | |
104 | + ) | |
105 | + ->one(); | |
106 | + | |
107 | + $dataProvider = new ActiveDataProvider( | |
108 | + [ | |
109 | + 'query' => $model->getArticles() | |
110 | + ->with( | |
111 | + [ | |
112 | + 'lang', | |
113 | + 'categories.lang', | |
114 | + ] | |
115 | + ) | |
116 | + ->orderBy( | |
117 | + [ | |
118 | + 'created_at' => SORT_DESC, | |
119 | + ] | |
120 | + ), | |
121 | + 'pagination' => [ | |
122 | + 'pageSize' => 3, | |
123 | + ], | |
124 | + ] | |
125 | + ); | |
126 | + | |
127 | + return $this->render( | |
128 | + 'category', | |
129 | + [ | |
130 | + 'tags' => $tags, | |
131 | + 'dataProvider' => $dataProvider, | |
132 | + 'model' => $model, | |
133 | + ] | |
134 | + ); | |
135 | + } | |
136 | + | |
137 | + public function actionTag($id) | |
138 | + { | |
139 | + $tags = Tag::find() | |
140 | + ->with( | |
141 | + [ | |
142 | + 'lang', | |
143 | + ] | |
144 | + ) | |
145 | + ->all(); | |
146 | + | |
147 | + /** | |
148 | + * @var Category $model | |
149 | + */ | |
150 | + $model = Tag::find() | |
151 | + ->where( | |
152 | + [ | |
153 | + 'id' => $id, | |
154 | + ] | |
155 | + ) | |
156 | + ->with( | |
157 | + [ | |
158 | + 'articles', | |
159 | + ] | |
160 | + ) | |
161 | + ->one(); | |
162 | + | |
163 | + $dataProvider = new ActiveDataProvider( | |
164 | + [ | |
165 | + 'query' => $model->getArticles() | |
166 | + ->with( | |
167 | + [ | |
168 | + 'lang', | |
169 | + 'categories.lang', | |
170 | + ] | |
171 | + ) | |
172 | + ->orderBy( | |
173 | + [ | |
174 | + 'created_at' => SORT_DESC, | |
175 | + ] | |
176 | + ), | |
177 | + 'pagination' => [ | |
178 | + 'pageSize' => 3, | |
179 | + ], | |
180 | + ] | |
181 | + ); | |
182 | + | |
183 | + return $this->render( | |
184 | + 'tag', | |
185 | + [ | |
186 | + 'tags' => $tags, | |
187 | + 'dataProvider' => $dataProvider, | |
188 | + 'model' => $model, | |
189 | + ] | |
190 | + ); | |
191 | + } | |
192 | + | |
193 | + /** | |
194 | + * @param $id | |
195 | + * | |
196 | + * @return Article | |
197 | + * @throws \yii\web\NotFoundHttpException | |
198 | + */ | |
199 | + protected function findModel($id) | |
200 | + { | |
201 | + /** | |
202 | + * @var Article | null $model | |
203 | + */ | |
204 | + $model = Article::find() | |
205 | + ->where([ 'id' => $id ]) | |
206 | + ->with( | |
207 | + [ | |
208 | + 'lang', | |
209 | + 'categories.lang', | |
210 | + 'tags.lang', | |
211 | + ] | |
212 | + ) | |
213 | + ->one(); | |
214 | + | |
215 | + if (empty($model)) { | |
216 | + throw new NotFoundHttpException(\Yii::t('app', 'Article not found')); | |
217 | + } else { | |
218 | + return $model; | |
219 | + } | |
220 | + } | |
39 | 221 | } |
40 | 222 | \ No newline at end of file | ... | ... |
frontend/views/blog/_article.php
1 | 1 | <?php |
2 | 2 | |
3 | + use artbox\core\helpers\ImageHelper; | |
3 | 4 | use artbox\weblog\models\Article; |
5 | + use yii\bootstrap\Html; | |
6 | + use yii\helpers\Url; | |
4 | 7 | |
5 | 8 | /** |
6 | 9 | * @var Article $model |
... | ... | @@ -11,25 +14,73 @@ |
11 | 14 | <section class="post"> |
12 | 15 | <div class="row"> |
13 | 16 | <div class="col-md-4"> |
14 | - <div class="video"> | |
15 | - <div class="embed-responsive embed-responsive-4by3"> | |
16 | - <iframe class="embed-responsive-item" src="//www.youtube.com/embed/upZJpGrppJA"></iframe> | |
17 | - </div> | |
17 | + <div class="image"> | |
18 | + <a href="<?= Url::to( | |
19 | + [ | |
20 | + 'blog/article', | |
21 | + 'id' => $model->id, | |
22 | + ] | |
23 | + ) ?>"> | |
24 | + <?= ImageHelper::set($model->image ? $model->image->getPath() : '@frontend/web/img/no-image.png') | |
25 | + ->cropResize(263, 197) | |
26 | + ->renderImage( | |
27 | + [ | |
28 | + 'class' => 'img-responsive', | |
29 | + 'alt' => $model->lang->title, | |
30 | + ] | |
31 | + ) ?> | |
32 | + </a> | |
18 | 33 | </div> |
19 | 34 | </div> |
20 | 35 | <div class="col-md-8"> |
21 | - <h2><a href="blog-post.html">Название статьи</a></h2> | |
36 | + <h2><a href="<?= Url::to( | |
37 | + [ | |
38 | + 'blog/article', | |
39 | + 'id' => $model->id, | |
40 | + ] | |
41 | + ) ?>"><?= $model->lang->title; ?></a></h2> | |
22 | 42 | <div class="clearfix"> |
23 | - <p class="author-category">Автор: <a href="#">John Snow</a> в <a href="blog.html">Webdesign</a> | |
24 | - </p> | |
43 | + <?php if (empty($model->categories)) { ?> | |
44 | + <p class="author-category">Без категории </p> | |
45 | + <?php } else { | |
46 | + $i = 0; | |
47 | + foreach ($model->categories as $category) { | |
48 | + $i++; | |
49 | + ?> | |
50 | + <p class="author-category"><?php | |
51 | + echo Html::a( | |
52 | + $category->lang->title, | |
53 | + [ | |
54 | + 'blog/category', | |
55 | + 'id' => $category->id, | |
56 | + ] | |
57 | + ); | |
58 | + if ($i === count($model->categories)) { | |
59 | + echo ' '; | |
60 | + } else { | |
61 | + echo ', '; | |
62 | + } | |
63 | + ?></p> | |
64 | + <?php | |
65 | + } | |
66 | + } ?> | |
25 | 67 | <p class="date-comments"> |
26 | - <a href="blog-post.html"><i class="fa fa-calendar-o"></i> 20 июня 2013</a> | |
27 | - <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 комментариев</a> | |
68 | + <i class="fa fa-calendar-o"></i> <?= \Yii::$app->formatter->asDate($model->created_at); ?> | |
69 | + <!-- <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 комментариев</a>--> | |
28 | 70 | </p> |
29 | 71 | </div> |
30 | - <p class="intro">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. | |
31 | - Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
32 | - <p class="read-more"><a href="blog-post.html" class="btn btn-template-main">Продолжить чтение</a> | |
72 | + <p class="intro"><?= $model->lang->body_preview; ?></p> | |
73 | + <p class="read-more"> | |
74 | + <?= Html::a( | |
75 | + 'Продолжить чтение', | |
76 | + [ | |
77 | + 'blog/article', | |
78 | + 'id' => $model->id, | |
79 | + ], | |
80 | + [ | |
81 | + 'class' => 'btn btn-template-main', | |
82 | + ] | |
83 | + ) ?> | |
33 | 84 | </p> |
34 | 85 | </div> |
35 | 86 | </div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use artbox\core\components\SeoComponent; | |
4 | + use artbox\weblog\models\Category; | |
5 | + use artbox\weblog\models\Tag; | |
6 | + use frontend\widgets\BlogSearch; | |
7 | + use yii\data\ActiveDataProvider; | |
8 | + use yii\helpers\Url; | |
9 | + use yii\web\View; | |
10 | + use yii\widgets\ListView; | |
11 | + | |
12 | + /** | |
13 | + * @var View $this | |
14 | + * @var ActiveDataProvider $dataProvider | |
15 | + * @var SeoComponent $seo | |
16 | + * @var Tag[] $tags | |
17 | + * @var Category $model | |
18 | + */ | |
19 | + $seo = \Yii::$app->get('seo'); | |
20 | + | |
21 | + $this->params[ 'breadcrumbs' ][] = [ | |
22 | + 'label' => \Yii::t('app', 'Блог'), | |
23 | + 'url' => [ 'blog/index' ], | |
24 | + ]; | |
25 | + | |
26 | + $this->params[ 'breadcrumbs' ][] = $seo->title; | |
27 | + | |
28 | +?> | |
29 | + | |
30 | +<div id="content"> | |
31 | + <div class="container"> | |
32 | + <div class="row"> | |
33 | + <!-- *** LEFT COLUMN *** | |
34 | +_________________________________________________________ --> | |
35 | + | |
36 | + | |
37 | + <!-- <ul class="pager">--> | |
38 | + <!-- <li class="previous"><a href="#">← Назад</a>--> | |
39 | + <!-- </li>--> | |
40 | + <!-- <li class="next disabled"><a href="#">Вперед →</a>--> | |
41 | + <!-- </li>--> | |
42 | + <!-- </ul>--> | |
43 | + | |
44 | + <!-- /.col-md-9 --> | |
45 | + | |
46 | + | |
47 | + <?= ListView::widget( | |
48 | + [ | |
49 | + 'dataProvider' => $dataProvider, | |
50 | + 'itemView' => '_article', | |
51 | + 'options' => [ | |
52 | + 'class' => 'col-md-9', | |
53 | + 'id' => 'blog-listing-medium', | |
54 | + ], | |
55 | + 'layout' => '{items}{pager}', | |
56 | + ] | |
57 | + ); ?> | |
58 | + | |
59 | + | |
60 | + <!-- *** LEFT COLUMN END *** --> | |
61 | + | |
62 | + <!-- *** RIGHT COLUMN *** | |
63 | +_________________________________________________________ --> | |
64 | + | |
65 | + <div class="col-md-3"> | |
66 | + | |
67 | + <!-- *** MENUS AND WIDGETS *** | |
68 | +_________________________________________________________ --> | |
69 | + <div class="panel panel-default sidebar-menu"> | |
70 | + | |
71 | + <div class="panel-heading"> | |
72 | + <h3 class="panel-title">Блог компании</h3> | |
73 | + </div> | |
74 | + | |
75 | + <div class="panel-body text-widget"> | |
76 | + <p> | |
77 | + Мы собираем полезные материалы по тематике бытовой техники и электроники | |
78 | + </p> | |
79 | + | |
80 | + </div> | |
81 | + </div> | |
82 | + | |
83 | + <?= BlogSearch::widget(); ?> | |
84 | + | |
85 | + <div class="panel sidebar-menu"> | |
86 | + <div class="panel-heading"> | |
87 | + <h3 class="panel-title">Поиск по тегам</h3> | |
88 | + </div> | |
89 | + | |
90 | + <div class="panel-body"> | |
91 | + <ul class="tag-cloud"> | |
92 | + <?php foreach ($tags as $tag) { ?> | |
93 | + <li><a href="<?= Url::to( | |
94 | + [ | |
95 | + 'blog/tag', | |
96 | + 'id' => $tag->id, | |
97 | + ] | |
98 | + ) ?>"><i class="fa fa-tags"></i> <?= $tag->lang->label; ?></a> | |
99 | + </li> | |
100 | + <?php } ?> | |
101 | + </ul> | |
102 | + </div> | |
103 | + </div> | |
104 | + | |
105 | + <!-- *** MENUS AND FILTERS END *** --> | |
106 | + | |
107 | + </div> | |
108 | + <!-- /.col-md-3 --> | |
109 | + | |
110 | + <!-- *** RIGHT COLUMN END *** --> | |
111 | + | |
112 | + </div> | |
113 | + <!-- /.row --> | |
114 | + </div> | |
115 | + <!-- /.container --> | |
116 | +</div> | |
117 | +<!-- /#content --> | |
0 | 118 | \ No newline at end of file | ... | ... |
frontend/views/blog/index.php
1 | 1 | <?php |
2 | 2 | |
3 | + use artbox\core\components\SeoComponent; | |
4 | + use artbox\weblog\models\Tag; | |
5 | + use frontend\widgets\BlogSearch; | |
3 | 6 | use yii\data\ActiveDataProvider; |
7 | + use yii\helpers\Url; | |
4 | 8 | use yii\web\View; |
5 | 9 | use yii\widgets\ListView; |
6 | 10 | |
7 | 11 | /** |
8 | 12 | * @var View $this |
9 | 13 | * @var ActiveDataProvider $dataProvider |
14 | + * @var SeoComponent $seo | |
15 | + * @var Tag[] $tags | |
10 | 16 | */ |
17 | + $seo = \Yii::$app->get('seo'); | |
18 | + | |
19 | + $this->params[ 'breadcrumbs' ][] = $seo->title; | |
11 | 20 | |
12 | 21 | ?> |
13 | 22 | |
... | ... | @@ -16,19 +25,15 @@ |
16 | 25 | <div class="row"> |
17 | 26 | <!-- *** LEFT COLUMN *** |
18 | 27 | _________________________________________________________ --> |
28 | + | |
29 | + | |
30 | + <!-- <ul class="pager">--> | |
31 | + <!-- <li class="previous"><a href="#">← Назад</a>--> | |
32 | + <!-- </li>--> | |
33 | + <!-- <li class="next disabled"><a href="#">Вперед →</a>--> | |
34 | + <!-- </li>--> | |
35 | + <!-- </ul>--> | |
19 | 36 | |
20 | - <div class="col-md-9" id="blog-listing-medium"> | |
21 | - | |
22 | - | |
23 | - <ul class="pager"> | |
24 | - <li class="previous"><a href="#">← Назад</a> | |
25 | - </li> | |
26 | - <li class="next disabled"><a href="#">Вперед →</a> | |
27 | - </li> | |
28 | - </ul> | |
29 | - | |
30 | - | |
31 | - </div> | |
32 | 37 | <!-- /.col-md-9 --> |
33 | 38 | |
34 | 39 | |
... | ... | @@ -40,6 +45,7 @@ _________________________________________________________ --> |
40 | 45 | 'class' => 'col-md-9', |
41 | 46 | 'id' => 'blog-listing-medium', |
42 | 47 | ], |
48 | + 'layout' => '{items}{pager}', | |
43 | 49 | ] |
44 | 50 | ); ?> |
45 | 51 | |
... | ... | @@ -66,26 +72,8 @@ _________________________________________________________ --> |
66 | 72 | |
67 | 73 | </div> |
68 | 74 | </div> |
69 | - | |
70 | - <div class="panel panel-default sidebar-menu"> | |
71 | - | |
72 | - <div class="panel-heading"> | |
73 | - <h3 class="panel-title">Поиск</h3> | |
74 | - </div> | |
75 | - | |
76 | - <div class="panel-body"> | |
77 | - <form role="search"> | |
78 | - <div class="input-group"> | |
79 | - <input type="text" class="form-control" placeholder="Поиск по статьям"> | |
80 | - <span class="input-group-btn"> | |
81 | - | |
82 | - <button type="submit" class="btn btn-template-main"><i class="fa fa-search"></i></button> | |
83 | - | |
84 | - </span> | |
85 | - </div> | |
86 | - </form> | |
87 | - </div> | |
88 | - </div> | |
75 | + | |
76 | + <?= BlogSearch::widget(); ?> | |
89 | 77 | |
90 | 78 | <div class="panel sidebar-menu"> |
91 | 79 | <div class="panel-heading"> |
... | ... | @@ -94,16 +82,15 @@ _________________________________________________________ --> |
94 | 82 | |
95 | 83 | <div class="panel-body"> |
96 | 84 | <ul class="tag-cloud"> |
97 | - <li><a href="#"><i class="fa fa-tags"></i> Обзор</a> | |
98 | - </li> | |
99 | - <li><a href="#"><i class="fa fa-tags"></i> Ноутбук</a> | |
100 | - </li> | |
101 | - <li><a href="#"><i class="fa fa-tags"></i> ПК</a> | |
102 | - </li> | |
103 | - <li><a href="#"><i class="fa fa-tags"></i> Моноблок</a> | |
104 | - </li> | |
105 | - <li><a href="#"><i class="fa fa-tags"></i> Смартфоны</a> | |
106 | - </li> | |
85 | + <?php foreach ($tags as $tag) { ?> | |
86 | + <li><a href="<?= Url::to( | |
87 | + [ | |
88 | + 'blog/tag', | |
89 | + 'id' => $tag->id, | |
90 | + ] | |
91 | + ) ?>"><i class="fa fa-tags"></i> <?= $tag->lang->label; ?></a> | |
92 | + </li> | |
93 | + <?php } ?> | |
107 | 94 | </ul> |
108 | 95 | </div> |
109 | 96 | </div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use artbox\core\components\SeoComponent; | |
4 | + use artbox\weblog\models\Tag; | |
5 | + use frontend\widgets\BlogSearch; | |
6 | + use yii\data\ActiveDataProvider; | |
7 | + use yii\helpers\Url; | |
8 | + use yii\web\View; | |
9 | + use yii\widgets\ListView; | |
10 | + | |
11 | + /** | |
12 | + * @var View $this | |
13 | + * @var ActiveDataProvider $dataProvider | |
14 | + * @var SeoComponent $seo | |
15 | + * @var Tag[] $tags | |
16 | + * @var Tag $model | |
17 | + */ | |
18 | + $seo = \Yii::$app->get('seo'); | |
19 | + | |
20 | + $this->params[ 'breadcrumbs' ][] = [ | |
21 | + 'label' => \Yii::t('app', 'Блог'), | |
22 | + 'url' => [ 'blog/index' ], | |
23 | + ]; | |
24 | + | |
25 | + $this->params[ 'breadcrumbs' ][] = $seo->title; | |
26 | + | |
27 | +?> | |
28 | + | |
29 | +<div id="content"> | |
30 | + <div class="container"> | |
31 | + <div class="row"> | |
32 | + <!-- *** LEFT COLUMN *** | |
33 | +_________________________________________________________ --> | |
34 | + | |
35 | + | |
36 | + <!-- <ul class="pager">--> | |
37 | + <!-- <li class="previous"><a href="#">← Назад</a>--> | |
38 | + <!-- </li>--> | |
39 | + <!-- <li class="next disabled"><a href="#">Вперед →</a>--> | |
40 | + <!-- </li>--> | |
41 | + <!-- </ul>--> | |
42 | + | |
43 | + <!-- /.col-md-9 --> | |
44 | + | |
45 | + | |
46 | + <?= ListView::widget( | |
47 | + [ | |
48 | + 'dataProvider' => $dataProvider, | |
49 | + 'itemView' => '_article', | |
50 | + 'options' => [ | |
51 | + 'class' => 'col-md-9', | |
52 | + 'id' => 'blog-listing-medium', | |
53 | + ], | |
54 | + 'layout' => '{items}{pager}', | |
55 | + ] | |
56 | + ); ?> | |
57 | + | |
58 | + | |
59 | + <!-- *** LEFT COLUMN END *** --> | |
60 | + | |
61 | + <!-- *** RIGHT COLUMN *** | |
62 | +_________________________________________________________ --> | |
63 | + | |
64 | + <div class="col-md-3"> | |
65 | + | |
66 | + <!-- *** MENUS AND WIDGETS *** | |
67 | +_________________________________________________________ --> | |
68 | + <div class="panel panel-default sidebar-menu"> | |
69 | + | |
70 | + <div class="panel-heading"> | |
71 | + <h3 class="panel-title">Блог компании</h3> | |
72 | + </div> | |
73 | + | |
74 | + <div class="panel-body text-widget"> | |
75 | + <p> | |
76 | + Мы собираем полезные материалы по тематике бытовой техники и электроники | |
77 | + </p> | |
78 | + | |
79 | + </div> | |
80 | + </div> | |
81 | + | |
82 | + <?= BlogSearch::widget(); ?> | |
83 | + | |
84 | + <div class="panel sidebar-menu"> | |
85 | + <div class="panel-heading"> | |
86 | + <h3 class="panel-title">Поиск по тегам</h3> | |
87 | + </div> | |
88 | + | |
89 | + <div class="panel-body"> | |
90 | + <ul class="tag-cloud"> | |
91 | + <?php foreach ($tags as $tag) { ?> | |
92 | + <li><a href="<?= Url::to( | |
93 | + [ | |
94 | + 'blog/tag', | |
95 | + 'id' => $tag->id, | |
96 | + ] | |
97 | + ) ?>"><i class="fa fa-tags"></i> <?= $tag->lang->label; ?></a> | |
98 | + </li> | |
99 | + <?php } ?> | |
100 | + </ul> | |
101 | + </div> | |
102 | + </div> | |
103 | + | |
104 | + <!-- *** MENUS AND FILTERS END *** --> | |
105 | + | |
106 | + </div> | |
107 | + <!-- /.col-md-3 --> | |
108 | + | |
109 | + <!-- *** RIGHT COLUMN END *** --> | |
110 | + | |
111 | + </div> | |
112 | + <!-- /.row --> | |
113 | + </div> | |
114 | + <!-- /.container --> | |
115 | +</div> | |
116 | +<!-- /#content --> | |
0 | 117 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use artbox\weblog\models\Article; | |
4 | + use artbox\weblog\models\Tag; | |
5 | + use frontend\widgets\BlogSearch; | |
6 | + use yii\helpers\Url; | |
7 | + use yii\web\View; | |
8 | + | |
9 | + /** | |
10 | + * @var View $this | |
11 | + * @var Article $model | |
12 | + * @var Tag[] $tags | |
13 | + */ | |
14 | + | |
15 | + $this->params[ 'breadcrumbs' ][] = [ | |
16 | + 'label' => \Yii::t('app', 'Блог'), | |
17 | + 'url' => [ 'blog/index' ], | |
18 | + ]; | |
19 | + | |
20 | + $this->params[ 'breadcrumbs' ][] = $model->lang->title; | |
21 | + | |
22 | +?> | |
23 | + | |
24 | +<div id="content"> | |
25 | + <div class="container"> | |
26 | + | |
27 | + <div class="row"> | |
28 | + | |
29 | + <!-- *** LEFT COLUMN *** | |
30 | +_________________________________________________________ --> | |
31 | + | |
32 | + <div class="col-md-9" id="blog-post"> | |
33 | + | |
34 | + <h2><?= $model->lang->title; ?></h2> | |
35 | + | |
36 | + <?php if (!empty($model->tags)) { ?> | |
37 | + <div class="panel sidebar-menu"> | |
38 | + <div class="panel-body"> | |
39 | + <ul class="tag-cloud"> | |
40 | + <?php foreach ($model->tags as $tag) { ?> | |
41 | + <li><a href="<?= Url::to( | |
42 | + [ | |
43 | + 'blog/tag', | |
44 | + 'id' => $tag->id, | |
45 | + ] | |
46 | + ) ?>"><i class="fa fa-tags"></i> <?= $tag->lang->label; ?></a> | |
47 | + </li> | |
48 | + <?php } ?> | |
49 | + </ul> | |
50 | + </div> | |
51 | + </div> | |
52 | + <?php } ?> | |
53 | + | |
54 | + <p class="text-muted text-uppercase mb-small text-left"><?= \Yii::$app->formatter->asDate( | |
55 | + $model->created_at | |
56 | + ); ?></p> | |
57 | + | |
58 | + <div id="post-content"> | |
59 | + | |
60 | + <?= $model->lang->body; ?> | |
61 | + | |
62 | + </div> | |
63 | + <!-- /#post-content --> | |
64 | + | |
65 | + <?php | |
66 | + /* | |
67 | + | |
68 | + <div id="comments"> | |
69 | + <h4 class="text-uppercase">2 comments</h4> | |
70 | + | |
71 | + | |
72 | + <div class="row comment"> | |
73 | + <div class="col-sm-3 col-md-2 text-center-xs"> | |
74 | + <p> | |
75 | + <img src="img/blog-avatar2.jpg" class="img-responsive img-circle" alt=""> | |
76 | + </p> | |
77 | + </div> | |
78 | + <div class="col-sm-9 col-md-10"> | |
79 | + <h5 class="text-uppercase">Julie Alma</h5> | |
80 | + <p class="posted"><i class="fa fa-clock-o"></i> September 23, 2011 в 12:00</p> | |
81 | + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. | |
82 | + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
83 | + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a> | |
84 | + </p> | |
85 | + </div> | |
86 | + </div> | |
87 | + <!-- /.comment --> | |
88 | + | |
89 | + | |
90 | + <div class="row comment last"> | |
91 | + | |
92 | + <div class="col-sm-3 col-md-2 text-center-xs"> | |
93 | + <p> | |
94 | + <img src="img/blog-avatar.jpg" class="img-responsive img-circle" alt=""> | |
95 | + </p> | |
96 | + </div> | |
97 | + | |
98 | + <div class="col-sm-9 col-md-10"> | |
99 | + <h5 class="text-uppercase">Louise Armero</h5> | |
100 | + <p class="posted"><i class="fa fa-clock-o"></i> 23 сентября 2012 в 12:00</p> | |
101 | + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. | |
102 | + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
103 | + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a> | |
104 | + </p> | |
105 | + </div> | |
106 | + | |
107 | + </div> | |
108 | + <!-- /.comment --> | |
109 | + </div> | |
110 | + <!-- /#comments --> | |
111 | + | |
112 | + | |
113 | + <div id="comment-form"> | |
114 | + | |
115 | + <h4 class="text-uppercase">Leave comment</h4> | |
116 | + | |
117 | + <form> | |
118 | + <div class="row"> | |
119 | + | |
120 | + <div class="col-sm-6"> | |
121 | + <div class="form-group"> | |
122 | + <label for="name">Name <span class="required">*</span> | |
123 | + </label> | |
124 | + <input type="text" class="form-control" id="name"> | |
125 | + </div> | |
126 | + </div> | |
127 | + | |
128 | + </div> | |
129 | + | |
130 | + <div class="row"> | |
131 | + <div class="col-sm-6"> | |
132 | + <div class="form-group"> | |
133 | + <label for="email">Email <span class="required">*</span> | |
134 | + </label> | |
135 | + <input type="text" class="form-control" id="email"> | |
136 | + </div> | |
137 | + </div> | |
138 | + </div> | |
139 | + | |
140 | + <div class="row"> | |
141 | + <div class="col-sm-12"> | |
142 | + <div class="form-group"> | |
143 | + <label for="comment">Comment <span class="required">*</span> | |
144 | + </label> | |
145 | + <textarea class="form-control" id="comment" rows="4"></textarea> | |
146 | + </div> | |
147 | + </div> | |
148 | + </div> | |
149 | + | |
150 | + <div class="row"> | |
151 | + <div class="col-sm-12 text-right"> | |
152 | + <button class="btn btn-template-main"><i class="fa fa-comment-o"></i> Post comment</button> | |
153 | + </div> | |
154 | + </div> | |
155 | + | |
156 | + | |
157 | + </form> | |
158 | + | |
159 | + </div> | |
160 | + <!-- /#comment-form --> | |
161 | + */ | |
162 | + ?> | |
163 | + </div> | |
164 | + <!-- /#blog-post --> | |
165 | + | |
166 | + <!-- *** LEFT COLUMN END *** --> | |
167 | + | |
168 | + <!-- *** RIGHT COLUMN *** | |
169 | + _________________________________________________________ --> | |
170 | + | |
171 | + <div class="col-md-3"> | |
172 | + | |
173 | + <!-- *** MENUS AND WIDGETS *** | |
174 | +_________________________________________________________ --> | |
175 | + <div class="panel panel-default sidebar-menu"> | |
176 | + | |
177 | + <div class="panel-heading"> | |
178 | + <h3 class="panel-title">Блог компании</h3> | |
179 | + </div> | |
180 | + | |
181 | + <div class="panel-body text-widget"> | |
182 | + <p> | |
183 | + Мы собираем полезные материалы по тематике бытовой техники и электроники | |
184 | + </p> | |
185 | + | |
186 | + </div> | |
187 | + </div> | |
188 | + | |
189 | + <?= BlogSearch::widget(); ?> | |
190 | + | |
191 | + <div class="panel sidebar-menu"> | |
192 | + <div class="panel-heading"> | |
193 | + <h3 class="panel-title">Поиск по тегам</h3> | |
194 | + </div> | |
195 | + | |
196 | + <div class="panel-body"> | |
197 | + <ul class="tag-cloud"> | |
198 | + <?php foreach ($tags as $tag) { ?> | |
199 | + <li><a href="<?= Url::to( | |
200 | + [ | |
201 | + 'blog/tag', | |
202 | + 'id' => $tag->id, | |
203 | + ] | |
204 | + ) ?>"><i class="fa fa-tags"></i> <?= $tag->lang->label; ?></a> | |
205 | + </li> | |
206 | + <?php } ?> | |
207 | + </ul> | |
208 | + </div> | |
209 | + </div> | |
210 | + | |
211 | + <!-- *** MENUS AND FILTERS END *** --> | |
212 | + | |
213 | + </div> | |
214 | + <!-- /.col-md-3 --> | |
215 | + <!-- *** RIGHT COLUMN END *** --> | |
216 | + | |
217 | + | |
218 | + </div> | |
219 | + <!-- /.row --> | |
220 | + | |
221 | + </div> | |
222 | + <!-- /.container --> | |
223 | +</div> | |
224 | +<!-- /#content --> | |
225 | + | |
0 | 226 | \ No newline at end of file | ... | ... |
frontend/views/layouts/main.php
... | ... | @@ -414,7 +414,34 @@ _________________________________________________________ --> |
414 | 414 | ?> |
415 | 415 | |
416 | 416 | <!-- *** LOGIN MODAL END *** --> |
417 | - | |
417 | + | |
418 | + | |
419 | + <!-- *** SUCCESS MODAL BEGIN *** | |
420 | + _________________________________________________________ --> | |
421 | + <div class="modal fade" id="success-modal" tabindex="-1" role="dialog" aria-labelledby="Success" aria-hidden="true"> | |
422 | + <div class="modal-dialog modal-sm"> | |
423 | + | |
424 | + <div class="modal-content"> | |
425 | + <div class="modal-header"> | |
426 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
427 | + <h4 class="modal-title" id="Success"> | |
428 | + Success Title | |
429 | + </h4> | |
430 | + </div> | |
431 | + <div class="modal-body"> | |
432 | + <p class="text-center text-muted"> | |
433 | + Success text 1</p> | |
434 | + <p class="text-center text-muted"> | |
435 | + Success text 2 | |
436 | + </p> | |
437 | + | |
438 | + </div> | |
439 | + </div> | |
440 | + </div> | |
441 | + </div> | |
442 | + | |
443 | + <!-- *** SUCCESS MODAL END *** --> | |
444 | + | |
418 | 445 | <!-- *** Breadcrumbs *** --> |
419 | 446 | <?php |
420 | 447 | if (!$isHome) { | ... | ... |
1 | +<?php | |
2 | + | |
3 | + namespace frontend\widgets; | |
4 | + | |
5 | + use yii\base\Widget; | |
6 | + | |
7 | + /** | |
8 | + * Class BlogSearch | |
9 | + * | |
10 | + * @package frontend\widgets | |
11 | + */ | |
12 | + class BlogSearch extends Widget | |
13 | + { | |
14 | + public function run() | |
15 | + { | |
16 | + return $this->render('_blog_search'); | |
17 | + } | |
18 | + } | |
0 | 19 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use yii\helpers\Url; | |
4 | + use yii\web\View; | |
5 | + | |
6 | + /** | |
7 | + * @var View $this | |
8 | + */ | |
9 | + | |
10 | +?> | |
11 | + | |
12 | +<div class="panel panel-default sidebar-menu"> | |
13 | + | |
14 | + <div class="panel-heading"> | |
15 | + <h3 class="panel-title">Поиск</h3> | |
16 | + </div> | |
17 | + | |
18 | + <div class="panel-body"> | |
19 | + <form role="search" action="<?= Url::to([ 'blog/index' ]) ?>" method="GET"> | |
20 | + <div class="input-group"> | |
21 | + <input type="text" class="form-control" name="q" placeholder="Поиск по статьям" value="<?= \Yii::$app->request->get( | |
22 | + 'q', | |
23 | + '' | |
24 | + ) ?>"> | |
25 | + <span class="input-group-btn"> | |
26 | + | |
27 | + <button type="submit" class="btn btn-template-main"><i class="fa fa-search"></i></button> | |
28 | + | |
29 | + </span> | |
30 | + </div> | |
31 | + </form> | |
32 | + </div> | |
33 | +</div> | ... | ... |