Commit 575afef8fd9daf510b1780fb17802d43c41dc948

Authored by Alexey Boroda
1 parent be89e918

-Blog half way done

backend/views/layouts/menu_items.php
@@ -30,20 +30,20 @@ @@ -30,20 +30,20 @@
30 }, 30 },
31 ], 31 ],
32 [ 32 [
33 - 'label' => \Yii::t('core', 'Static pages'),  
34 - 'url' => '#',  
35 - 'icon' => 'file-text', 33 + 'label' => \Yii::t('core', 'Static pages'),
  34 + 'url' => '#',
  35 + 'icon' => 'file-text',
36 'items' => [ 36 'items' => [
37 [ 37 [
38 - 'label' => \Yii::t('core', 'Pages'),  
39 - 'url' => [ '/page/index' ],  
40 - 'icon' => 'file-text', 38 + 'label' => \Yii::t('core', 'Pages'),
  39 + 'url' => [ '/page/index' ],
  40 + 'icon' => 'file-text',
41 ], 41 ],
42 [ 42 [
43 - 'label' => \Yii::t('core', 'Categories'),  
44 - 'url' => [ '/page-category/index' ],  
45 - 'icon' => 'archive',  
46 - ] 43 + 'label' => \Yii::t('core', 'Categories'),
  44 + 'url' => [ '/page-category/index' ],
  45 + 'icon' => 'archive',
  46 + ],
47 ], 47 ],
48 ], 48 ],
49 [ 49 [
@@ -96,9 +96,14 @@ @@ -96,9 +96,14 @@
96 ], 96 ],
97 ], 97 ],
98 [ 98 [
99 - 'label' => \Yii::t('core', 'Image manager'),  
100 - 'url' => [ '/imagemanager' ],  
101 - 'icon' => 'image', 99 + 'label' => \Yii::t('core', 'Image manager'),
  100 + 'url' => [ '/imagemanager' ],
  101 + 'icon' => 'image',
  102 + ],
  103 + [
  104 + 'label' => \Yii::t('artbox-comment', 'Comments'),
  105 + 'url' => [ '/comment' ],
  106 + 'icon' => 'comment',
102 ], 107 ],
103 ] 108 ]
104 ); 109 );
105 \ No newline at end of file 110 \ No newline at end of file
frontend/controllers/BlogController.php
@@ -36,4 +36,28 @@ @@ -36,4 +36,28 @@
36 ] 36 ]
37 ); 37 );
38 } 38 }
  39 +
  40 + public function actionCategory()
  41 + {
  42 + $query = Article::find()
  43 + ->with('lang.alias')
  44 + ->with('image')
  45 + ->where([ 'status' => true ]);
  46 +
  47 + $dataProvider = new ActiveDataProvider(
  48 + [
  49 + 'query' => $query,
  50 + 'pagination' => [
  51 + 'pageSize' => 3,
  52 + ],
  53 + ]
  54 + );
  55 +
  56 + return $this->render(
  57 + 'index',
  58 + [
  59 + 'dataProvider' => $dataProvider,
  60 + ]
  61 + );
  62 + }
39 } 63 }
40 \ No newline at end of file 64 \ No newline at end of file
frontend/views/blog/_article.php
1 <?php 1 <?php
2 2
  3 + use artbox\core\helpers\ImageHelper;
3 use artbox\weblog\models\Article; 4 use artbox\weblog\models\Article;
  5 + use yii\helpers\Url;
4 6
5 /** 7 /**
6 * @var Article $model 8 * @var Article $model
@@ -8,26 +10,59 @@ @@ -8,26 +10,59 @@
8 ?> 10 ?>
9 11
10 <section class="post"> 12 <section class="post">
11 - <h2><a href="post.htmls">Fashion now</a></h2> 13 + <h2><a href="<?= Url::to(
  14 + [
  15 + 'blog/article',
  16 + 'alias' => $model->lang->alias,
  17 + ]
  18 + ) ?>"><?= $model->lang->title ?></a></h2>
12 <div class="row"> 19 <div class="row">
13 <div class="col-sm-6"> 20 <div class="col-sm-6">
14 - <p class="author-category">By <a href="#">John Snow</a> in <a href="blog.html">Webdesign</a> 21 + <p class="author-category"><a href="blog.html">Webdesign</a>
15 </p> 22 </p>
16 </div> 23 </div>
17 <div class="col-sm-6"> 24 <div class="col-sm-6">
18 <p class="date-comments"> 25 <p class="date-comments">
19 - <a href="blog-post.html"><i class="fa fa-calendar-o"></i><?=date('d M, Y', $model->created_at)?></a>  
20 - <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 Comments</a> 26 + <a href="<?= Url::to(
  27 + [
  28 + 'blog/article',
  29 + 'alias' => $model->lang->alias,
  30 + ]
  31 + ) ?>"><i class="fa fa-calendar-o"></i><?= date('d M, Y', $model->created_at) ?></a>
  32 + <a href="<?= Url::to(
  33 + [
  34 + 'blog/article',
  35 + 'alias' => $model->lang->alias,
  36 + ]
  37 + ) ?>"><i class="fa fa-comment-o"></i> 8 Comments</a>
21 </p> 38 </p>
22 </div> 39 </div>
23 </div> 40 </div>
24 <div class="image"> 41 <div class="image">
25 - <a href="blog-post.html">  
26 - <img src="img/blog2.jpg" class="img-responsive" alt="Example blog post alt"> 42 + <a href="<?= Url::to(
  43 + [
  44 + 'blog/article',
  45 + 'alias' => $model->lang->alias,
  46 + ]
  47 + ) ?>">
  48 + <?= ImageHelper::set(
  49 + ( empty($model->image) ? \Yii::getAlias('@frontend/web/img/no-image.png') : $model->image->getPath() )
  50 + )
  51 + ->resize(600, 300)
  52 + ->renderImage(
  53 + [
  54 + 'class' => 'img-responsive',
  55 + 'alt' => $model->lang->title,
  56 + ]
  57 + ) ?>
27 </a> 58 </a>
28 </div> 59 </div>
29 - <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. Aenean  
30 - ultricies mi vitae est. Mauris placerat eleifend leo.</p>  
31 - <p class="read-more"><a href="blog-post.html" class="btn btn-template-main">Continue reading</a> 60 + <p class="intro"><?=$model->lang->body_preview?></p>
  61 + <p class="read-more"><a href="<?= Url::to(
  62 + [
  63 + 'blog/article',
  64 + 'alias' => $model->lang->alias,
  65 + ]
  66 + ) ?>" class="btn btn-template-main">Continue reading</a>
32 </p> 67 </p>
33 </section> 68 </section>
frontend/views/layouts/main.php
@@ -299,6 +299,10 @@ @@ -299,6 +299,10 @@
299 'url' => [ 'site/price' ], 299 'url' => [ 'site/price' ],
300 ]; 300 ];
301 $items[] = [ 301 $items[] = [
  302 + 'label' => \Yii::t('app', 'Блог'),
  303 + 'url' => [ 'blog/index' ],
  304 + ];
  305 + $items[] = [
302 'label' => \Yii::t('app', 'Контакты'), 306 'label' => \Yii::t('app', 'Контакты'),
303 'url' => [ 'site/contact' ], 307 'url' => [ 'site/contact' ],
304 ]; 308 ];