Commit 30a01994c459ae08d2389627dc70c88b7bf92f06
1 parent
35f6909f
blog
Showing
14 changed files
with
458 additions
and
21 deletions
Show diff stats
backend/config/main.php
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | 'alias' => 'artbox\core\controllers\AliasController', |
| 24 | 24 | 'seo' => 'artbox\core\controllers\SeoController', |
| 25 | 25 | 'feedback' => 'artbox\core\controllers\FeedbackController', |
| 26 | + 'blog' => 'artbox\weblog\controllers\ArticleController', | |
| 26 | 27 | ], |
| 27 | 28 | 'components' => [ |
| 28 | 29 | 'assetManager' => [ | ... | ... |
backend/views/layouts/menu_items.php
common/config/bootstrap.php
| ... | ... | @@ -6,4 +6,7 @@ |
| 6 | 6 | Yii::setAlias('@storage', dirname(dirname(__DIR__)) . '/storage'); |
| 7 | 7 | if (!Yii::getAlias('@artbox/core', false)) { |
| 8 | 8 | Yii::setAlias('@artbox/core', dirname(dirname(__DIR__)) . '/artweb/artbox-core'); |
| 9 | + } | |
| 10 | + if (!Yii::getAlias('@artbox/weblog', false)) { | |
| 11 | + Yii::setAlias('@artbox/weblog', dirname(dirname(__DIR__)) . '/artweb/artbox-weblog'); | |
| 9 | 12 | } |
| 10 | 13 | \ No newline at end of file | ... | ... |
common/config/main.php
composer.json
| ... | ... | @@ -31,7 +31,8 @@ |
| 31 | 31 | "speixoto/yii2-amcharts": "^0.1.1", |
| 32 | 32 | "2amigos/yii2-tinymce-widget": "~1.1", |
| 33 | 33 | "kartik-v/yii2-widget-select2": "@dev", |
| 34 | - "artweb/artbox-core": "@dev" | |
| 34 | + "artweb/artbox-core": "@dev", | |
| 35 | + "artweb/artbox-weblog": "@dev" | |
| 35 | 36 | }, |
| 36 | 37 | "require-dev": { |
| 37 | 38 | "yiisoft/yii2-debug": "~2.0.0", |
| ... | ... | @@ -53,6 +54,10 @@ |
| 53 | 54 | { |
| 54 | 55 | "type": "vcs", |
| 55 | 56 | "url": "git@gitlab.artweb.com.ua:yarik.nechyporuk/artbox-core.git" |
| 57 | + }, | |
| 58 | + { | |
| 59 | + "type": "vcs", | |
| 60 | + "url": "git@gitlab.artweb.com.ua:Alexey/artbox-weblog.git" | |
| 56 | 61 | } |
| 57 | 62 | ] |
| 58 | 63 | } | ... | ... |
frontend/config/main.php
| 1 | +<?php | |
| 2 | + namespace frontend\controllers; | |
| 3 | + | |
| 4 | + use yii\data\ActiveDataProvider; | |
| 5 | + use yii\web\Controller; | |
| 6 | + use artbox\weblog\models\Article; | |
| 7 | + use yii\web\NotFoundHttpException; | |
| 8 | + | |
| 9 | + /** | |
| 10 | + * User: timur | |
| 11 | + * Date: 26.01.18 | |
| 12 | + * Time: 8:46 | |
| 13 | + */ | |
| 14 | + | |
| 15 | + class BlogController extends Controller | |
| 16 | + { | |
| 17 | + public function actionIndex() | |
| 18 | + { | |
| 19 | + | |
| 20 | + $dataProvider = new ActiveDataProvider( | |
| 21 | + [ | |
| 22 | + 'query' => Article::find() | |
| 23 | + ->where( | |
| 24 | + [ | |
| 25 | + 'status' => true, | |
| 26 | + ] | |
| 27 | + ), | |
| 28 | + 'pagination' => [ | |
| 29 | + 'pageSize' => 5, | |
| 30 | + ], | |
| 31 | + ] | |
| 32 | + ); | |
| 33 | + | |
| 34 | + return $this->render( | |
| 35 | + 'index', | |
| 36 | + [ | |
| 37 | + 'dataProvider' => $dataProvider, | |
| 38 | + ] | |
| 39 | + ); | |
| 40 | + } | |
| 41 | + | |
| 42 | + public function actionArticle($id) | |
| 43 | + { | |
| 44 | + | |
| 45 | + $model = $this->findModel($id); | |
| 46 | + | |
| 47 | + return $this->render( | |
| 48 | + 'view', | |
| 49 | + [ | |
| 50 | + 'article' => $model, | |
| 51 | + ] | |
| 52 | + ); | |
| 53 | + | |
| 54 | + } | |
| 55 | + | |
| 56 | + protected function findModel($id) | |
| 57 | + { | |
| 58 | + /** | |
| 59 | + * Some comment | |
| 60 | + */ | |
| 61 | + | |
| 62 | + $model = Article::find() | |
| 63 | + ->where( | |
| 64 | + [ | |
| 65 | + 'id' => $id | |
| 66 | + ] | |
| 67 | + ) | |
| 68 | + ->with("lang") | |
| 69 | + ->one(); | |
| 70 | + | |
| 71 | + if ( $model !== NULL) { | |
| 72 | + return $model; | |
| 73 | + } | |
| 74 | + else { | |
| 75 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + } | |
| 0 | 80 | \ No newline at end of file | ... | ... |
frontend/controllers/ObjectController.php
| ... | ... | @@ -13,6 +13,24 @@ |
| 13 | 13 | |
| 14 | 14 | class ObjectController extends Controller |
| 15 | 15 | { |
| 16 | + | |
| 17 | + public function actionIndex() | |
| 18 | + { | |
| 19 | + | |
| 20 | + $objects = Objectkb::find() | |
| 21 | + ->where(['status'=>true]) | |
| 22 | + ->with("lang.alias") | |
| 23 | + ->with("image") | |
| 24 | + ->all(); | |
| 25 | + | |
| 26 | + return $this->render( | |
| 27 | + 'index', | |
| 28 | + [ | |
| 29 | + 'objects' => $objects, | |
| 30 | + ] | |
| 31 | + ); | |
| 32 | + } // наши объекты | |
| 33 | + | |
| 16 | 34 | public function actionView($id) |
| 17 | 35 | { |
| 18 | 36 | ... | ... |
frontend/controllers/SiteController.php
| ... | ... | @@ -100,23 +100,6 @@ |
| 100 | 100 | return $this->render('legal'); |
| 101 | 101 | } // юридическое |
| 102 | 102 | |
| 103 | - public function actionObjects() | |
| 104 | - { | |
| 105 | - | |
| 106 | - $objects = Objectkb::find() | |
| 107 | - ->where(['status'=>true]) | |
| 108 | - ->with("lang.alias") | |
| 109 | - ->with("image") | |
| 110 | - ->all(); | |
| 111 | - | |
| 112 | - return $this->render( | |
| 113 | - 'objects', | |
| 114 | - [ | |
| 115 | - 'objects' => $objects, | |
| 116 | - ] | |
| 117 | - ); | |
| 118 | - } // наши объекты | |
| 119 | - | |
| 120 | 103 | public function actionGreen() |
| 121 | 104 | { |
| 122 | 105 | return $this->render('green'); | ... | ... |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * User: timur | |
| 4 | + * Date: 26.01.18 | |
| 5 | + * Time: 9:04 | |
| 6 | + * | |
| 7 | + * @var Article $model | |
| 8 | + */ | |
| 9 | + | |
| 10 | + use artbox\weblog\models\Article; | |
| 11 | + use yii\helpers\Url; | |
| 12 | + | |
| 13 | + ?> | |
| 14 | + | |
| 15 | +<section class="post"> | |
| 16 | + <h2 class="big-text-2"> | |
| 17 | + <a | |
| 18 | + href="<?=Url::toRoute( | |
| 19 | + [ | |
| 20 | + 'blog/article', | |
| 21 | + 'alias' => $model->lang->alias | |
| 22 | + ] | |
| 23 | + )?>" | |
| 24 | + > | |
| 25 | + <?=$model->lang->title?> | |
| 26 | + </a> | |
| 27 | + </h2> | |
| 28 | + <div class="row"> | |
| 29 | + <div class="col-sm-6"> | |
| 30 | + <p class="author-category"> | |
| 31 | + By <a href="blog.html#">Николас</a> | |
| 32 | + in <a href="blog.html">NicolasBW</a> | |
| 33 | + </p> | |
| 34 | + </div> | |
| 35 | + <div class="col-sm-6"> | |
| 36 | + <p class="date-comments"> | |
| 37 | + <a href="blog-post.html"><i class="fa fa-calendar-o"></i> 20 июня 2013</a> | |
| 38 | + <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 комментариев</a> | |
| 39 | + </p> | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | + <div class="image" style="height: 352px;"> | |
| 43 | + <a | |
| 44 | + href="<?=Url::toRoute( | |
| 45 | + [ | |
| 46 | + 'blog/article', | |
| 47 | + 'alias' => $model->lang->alias | |
| 48 | + ] | |
| 49 | + )?>" | |
| 50 | + > | |
| 51 | + <?=$model->image->getImg( | |
| 52 | + [ | |
| 53 | + 'class' => "img-responsive" | |
| 54 | + ] | |
| 55 | + )?> | |
| 56 | +<!-- <img src="img/photo01.jpg" class="img-responsive" alt="Example blog post alt">--> | |
| 57 | + </a> | |
| 58 | + </div> | |
| 59 | + <p class="intro"> | |
| 60 | + <?=$model->lang->body_preview?> | |
| 61 | + </p> | |
| 62 | + <p class="read-more"> | |
| 63 | + <a | |
| 64 | + href="<?=Url::toRoute( | |
| 65 | + [ | |
| 66 | + 'blog/article', | |
| 67 | + 'alias' => $model->lang->alias | |
| 68 | + ] | |
| 69 | + )?>" | |
| 70 | + class="btn btn-template-main" | |
| 71 | + > | |
| 72 | + Читать далее | |
| 73 | + </a> | |
| 74 | + </p> | |
| 75 | +</section> | ... | ... |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * User: timur | |
| 4 | + * Date: 26.01.18 | |
| 5 | + * Time: 8:49 | |
| 6 | + * | |
| 7 | + * @var View $this | |
| 8 | + * @var ActiveDataProvider $dataProvider | |
| 9 | + */ | |
| 10 | + | |
| 11 | + use yii\web\View; | |
| 12 | + use yii\data\ActiveDataProvider; | |
| 13 | + use yii\widgets\ListView; | |
| 14 | + | |
| 15 | + ?> | |
| 16 | + | |
| 17 | +<div id="content"> | |
| 18 | + <div class="container"> | |
| 19 | + <div class="row"> | |
| 20 | + | |
| 21 | + <div class="col-md-9" id="blog-listing-big"> | |
| 22 | + | |
| 23 | + <?=ListView::widget( | |
| 24 | + [ | |
| 25 | + 'dataProvider' => $dataProvider, | |
| 26 | + 'itemView' => '_article_item', | |
| 27 | + 'layout' => '{items}{pager}', | |
| 28 | + 'pager' => [ | |
| 29 | + 'disableCurrentPageButton' => true, | |
| 30 | + 'registerLinkTags' => true, | |
| 31 | + ], | |
| 32 | + ] | |
| 33 | + )?> | |
| 34 | + | |
| 35 | + </div> | |
| 36 | + | |
| 37 | + | |
| 38 | + </div> | |
| 39 | + </div> | |
| 40 | +</div> | |
| 0 | 41 | \ No newline at end of file | ... | ... |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * User: timur | |
| 4 | + * Date: 26.01.18 | |
| 5 | + * Time: 9:22 | |
| 6 | + * | |
| 7 | + * @var Article $article | |
| 8 | + */ | |
| 9 | + | |
| 10 | + use artbox\weblog\models\Article; | |
| 11 | + | |
| 12 | +?> | |
| 13 | + | |
| 14 | +<div id="content"> | |
| 15 | + <div class="container"> | |
| 16 | + | |
| 17 | + <div class="row"> | |
| 18 | + | |
| 19 | + <!-- *** LEFT COLUMN *** | |
| 20 | + _________________________________________________________ --> | |
| 21 | + | |
| 22 | + <div class="col-md-9" id="blog-post"> | |
| 23 | + | |
| 24 | + | |
| 25 | + <p class="text-muted text-uppercase mb-small text-right">By <a href="blog-post.html#">copywriter</a> in TravelBlog</p> | |
| 26 | + | |
| 27 | + <p class="lead"> | |
| 28 | + <?=$article->lang->title?> | |
| 29 | + </p> | |
| 30 | + | |
| 31 | + <div id="post-content"> | |
| 32 | + <p> | |
| 33 | + Лофотенский архипелаг расположен в Норвежском море. Он представляет собой скалистые острова, разделенные узкими проливами с дикими бухтами, песчаными пляжами и чистейшей водой. | |
| 34 | + </p> | |
| 35 | + | |
| 36 | + <p> | |
| 37 | + <?=$article->image->getImg( | |
| 38 | + [ | |
| 39 | + 'class' => "img-responsive" | |
| 40 | + ] | |
| 41 | + )?> | |
| 42 | +<!-- <img src="img/norv.jpg" class="img-responsive" alt="Example blog post alt">--> | |
| 43 | + </p> | |
| 44 | + | |
| 45 | + <?=$article->lang->body?> | |
| 46 | + | |
| 47 | + </div> | |
| 48 | + <!-- /#post-content --> | |
| 49 | + | |
| 50 | +<!-- <div id="comments">--> | |
| 51 | +<!-- <h4 class="text-uppercase">2 комментария</h4>--> | |
| 52 | +<!-- --> | |
| 53 | +<!-- --> | |
| 54 | +<!-- <div class="row comment">--> | |
| 55 | +<!-- <div class="col-sm-3 col-md-2 text-center-xs">--> | |
| 56 | +<!-- <p>--> | |
| 57 | +<!-- <img src="img/blog-avatar2.jpg" class="img-responsive img-circle" alt="">--> | |
| 58 | +<!-- </p>--> | |
| 59 | +<!-- </div>--> | |
| 60 | +<!-- <div class="col-sm-9 col-md-10">--> | |
| 61 | +<!-- <h5 class="text-uppercase">carolina</h5>--> | |
| 62 | +<!-- <p class="posted"><i class="fa fa-clock-o"></i> 23 сентября, 2011, 12:00</p>--> | |
| 63 | +<!-- <p>Спасибо! Давно хочу съездить в Норвегию. Вот и определилась куда.</p>--> | |
| 64 | +<!-- <p class="reply"><a href="blog-post.html#"><i class="fa fa-reply"></i> Ответить</a>--> | |
| 65 | +<!-- </p>--> | |
| 66 | +<!-- </div>--> | |
| 67 | +<!-- </div>--> | |
| 68 | +<!-- <!-- /.comment -->--> | |
| 69 | +<!-- --> | |
| 70 | +<!-- --> | |
| 71 | +<!-- <div class="row comment last">--> | |
| 72 | +<!-- --> | |
| 73 | +<!-- <div class="col-sm-3 col-md-2 text-center-xs">--> | |
| 74 | +<!-- <p>--> | |
| 75 | +<!-- <img src="img/blog-avatar.jpg" class="img-responsive img-circle" alt="">--> | |
| 76 | +<!-- </p>--> | |
| 77 | +<!-- </div>--> | |
| 78 | +<!-- --> | |
| 79 | +<!-- <div class="col-sm-9 col-md-10">--> | |
| 80 | +<!-- <h5 class="text-uppercase">gigi2</h5>--> | |
| 81 | +<!-- <p class="posted"><i class="fa fa-clock-o"></i> 23 сентября, 2011, 12:00</p>--> | |
| 82 | +<!-- <p>Даже и не знал, что на рыбалку лучше ехать в Квальвику. У меня туда друг часто катается со своей женой, может с ними теперь поеду. Давно не занимался рыбалкой зарубежом.</p>--> | |
| 83 | +<!-- <p class="reply"><a href="blog-post.html#"><i class="fa fa-reply"></i> Ответить</a>--> | |
| 84 | +<!-- </p>--> | |
| 85 | +<!-- </div>--> | |
| 86 | +<!-- --> | |
| 87 | +<!-- </div>--> | |
| 88 | +<!-- </div>--> | |
| 89 | + <!-- /#comments --> | |
| 90 | + | |
| 91 | + | |
| 92 | +<!-- <div id="comment-form">--> | |
| 93 | +<!-- --> | |
| 94 | +<!-- <h4 class="text-uppercase">Оставить комментарий</h4>--> | |
| 95 | +<!-- --> | |
| 96 | +<!-- <form>--> | |
| 97 | +<!-- <div class="row">--> | |
| 98 | +<!-- --> | |
| 99 | +<!-- <div class="col-sm-6">--> | |
| 100 | +<!-- <div class="form-group">--> | |
| 101 | +<!-- <label for="name">Имя <span class="required">*</span>--> | |
| 102 | +<!-- </label>--> | |
| 103 | +<!-- <input type="text" class="form-control" id="name">--> | |
| 104 | +<!-- </div>--> | |
| 105 | +<!-- </div>--> | |
| 106 | +<!-- --> | |
| 107 | +<!-- </div>--> | |
| 108 | +<!-- --> | |
| 109 | +<!-- <div class="row">--> | |
| 110 | +<!-- <div class="col-sm-6">--> | |
| 111 | +<!-- <div class="form-group">--> | |
| 112 | +<!-- <label for="email">Email <span class="required">*</span>--> | |
| 113 | +<!-- </label>--> | |
| 114 | +<!-- <input type="text" class="form-control" id="email">--> | |
| 115 | +<!-- </div>--> | |
| 116 | +<!-- </div>--> | |
| 117 | +<!-- </div>--> | |
| 118 | +<!-- --> | |
| 119 | +<!-- <div class="row">--> | |
| 120 | +<!-- <div class="col-sm-12">--> | |
| 121 | +<!-- <div class="form-group">--> | |
| 122 | +<!-- <label for="comment">Текст комментария <span class="required">*</span>--> | |
| 123 | +<!-- </label>--> | |
| 124 | +<!-- <textarea class="form-control" id="comment" rows="4"></textarea>--> | |
| 125 | +<!-- </div>--> | |
| 126 | +<!-- </div>--> | |
| 127 | +<!-- </div>--> | |
| 128 | +<!-- --> | |
| 129 | +<!-- <div class="row">--> | |
| 130 | +<!-- <div class="col-sm-12 text-right">--> | |
| 131 | +<!-- <button class="btn btn-template-main"><i class="fa fa-comment-o"></i> Отправить</button>--> | |
| 132 | +<!-- </div>--> | |
| 133 | +<!-- </div>--> | |
| 134 | +<!-- --> | |
| 135 | +<!-- --> | |
| 136 | +<!-- </form>--> | |
| 137 | +<!-- --> | |
| 138 | +<!-- </div>--> | |
| 139 | + <!-- /#comment-form --> | |
| 140 | + | |
| 141 | + | |
| 142 | + </div> | |
| 143 | + <!-- /#blog-post --> | |
| 144 | + | |
| 145 | + <!-- *** LEFT COLUMN END *** --> | |
| 146 | + | |
| 147 | + <!-- *** RIGHT COLUMN *** | |
| 148 | + _________________________________________________________ --> | |
| 149 | + | |
| 150 | + <div class="col-md-3"> | |
| 151 | + | |
| 152 | + <!-- *** MENUS AND WIDGETS *** | |
| 153 | +_________________________________________________________ --> | |
| 154 | + | |
| 155 | + | |
| 156 | + <div class="panel panel-default sidebar-menu"> | |
| 157 | +<!-- --> | |
| 158 | +<!-- <div class="panel-heading">--> | |
| 159 | +<!-- <h3 class="panel-title">Поиск</h3>--> | |
| 160 | +<!-- </div>--> | |
| 161 | +<!-- --> | |
| 162 | +<!-- <div class="panel-body">--> | |
| 163 | +<!-- <form role="search">--> | |
| 164 | +<!-- <div class="input-group">--> | |
| 165 | +<!-- <input type="text" class="form-control" placeholder="Поиск">--> | |
| 166 | +<!-- <span class="input-group-btn">--> | |
| 167 | +<!-- <button type="submit" class="btn btn-template-main"><i class="fa fa-search"></i></button>--> | |
| 168 | +<!-- </span>--> | |
| 169 | +<!-- </div>--> | |
| 170 | +<!-- </form>--> | |
| 171 | +<!-- </div>--> | |
| 172 | + </div> | |
| 173 | + | |
| 174 | + <div class="panel panel-default sidebar-menu"> | |
| 175 | + | |
| 176 | + <div class="panel-heading"> | |
| 177 | + <h3 class="panel-title">Категории</h3> | |
| 178 | + </div> | |
| 179 | + | |
| 180 | + <div class="panel-body"> | |
| 181 | + <ul class="nav nav-pills nav-stacked"> | |
| 182 | + <li><a href="blog.html">Норвегия</a> | |
| 183 | + </li> | |
| 184 | + <li><a href="blog.html">Путешествие</a> | |
| 185 | + </li> | |
| 186 | + <li><a href="blog.html">Маршрут</a> | |
| 187 | + </li> | |
| 188 | + </ul> | |
| 189 | + </div> | |
| 190 | + </div> | |
| 191 | + | |
| 192 | + <div class="panel sidebar-menu"> | |
| 193 | + <div class="panel-heading"> | |
| 194 | + <h3 class="panel-title">Теги</h3> | |
| 195 | + </div> | |
| 196 | + | |
| 197 | + <div class="panel-body"> | |
| 198 | + <ul class="tag-cloud"> | |
| 199 | + <li><a href="blog-post.html#"><i class="fa fa-tags"></i> traveling</a> | |
| 200 | + </li> | |
| 201 | + <li><a href="blog-post.html#"><i class="fa fa-tags"></i> travel</a> | |
| 202 | + </li> | |
| 203 | + <li><a href="blog-post.html#"><i class="fa fa-tags"></i> travelguide</a> | |
| 204 | + </li> | |
| 205 | + <li><a href="blog-post.html#"><i class="fa fa-tags"></i> advice</a> | |
| 206 | + </li> | |
| 207 | + </ul> | |
| 208 | + </div> | |
| 209 | + </div> | |
| 210 | + | |
| 211 | + <!-- *** MENUS AND FILTERS END *** --> | |
| 212 | + | |
| 213 | + </div> | |
| 214 | + <!-- /.col-md-3 --> | |
| 215 | + | |
| 216 | + <!-- *** RIGHT COLUMN END *** --> | |
| 217 | + | |
| 218 | + | |
| 219 | + </div> | |
| 220 | + <!-- /.row --> | |
| 221 | + | |
| 222 | + </div> | |
| 223 | + <!-- /.container --> | |
| 224 | +</div> | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -307,7 +307,7 @@ _________________________________________________________ --> |
| 307 | 307 | ]; |
| 308 | 308 | $items[] = [ |
| 309 | 309 | 'label' => \Yii::t('app', 'menu-objects'), |
| 310 | - 'url' => [ 'site/objects' ], | |
| 310 | + 'url' => [ 'object/index' ], | |
| 311 | 311 | ]; |
| 312 | 312 | $items[] = [ |
| 313 | 313 | 'label' => \Yii::t('app', 'menu-green'), |
| ... | ... | @@ -319,7 +319,7 @@ _________________________________________________________ --> |
| 319 | 319 | ]; |
| 320 | 320 | $items[] = [ |
| 321 | 321 | 'label' => \Yii::t('app', 'menu-blog'), |
| 322 | - 'url' => [ 'site/blog' ], | |
| 322 | + 'url' => [ 'blog/index' ], | |
| 323 | 323 | ]; |
| 324 | 324 | $items[] = [ |
| 325 | 325 | 'label' => \Yii::t('app', 'menu-contacts'), | ... | ... |
frontend/views/site/objects.php renamed to frontend/views/object/index.php