Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
c9eeb2d5
Commit
c9eeb2d5
authored
Feb 11, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tag page
parent
73c5f333
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
3 deletions
+106
-3
common/modules/blog/controllers/PostController.php
common/modules/blog/controllers/PostController.php
+21
-0
common/modules/blog/models/PostTag.php
common/modules/blog/models/PostTag.php
+7
-0
common/modules/blog/views/post/_sidebar.php
common/modules/blog/views/post/_sidebar.php
+1
-1
common/modules/blog/views/post/index.php
common/modules/blog/views/post/index.php
+1
-1
common/modules/blog/views/post/tag.php
common/modules/blog/views/post/tag.php
+73
-0
common/modules/blog/views/post/view.php
common/modules/blog/views/post/view.php
+1
-1
frontend/config/main.php
frontend/config/main.php
+1
-0
frontend/messages/ru-RU/app.php
frontend/messages/ru-RU/app.php
+1
-0
No files found.
common/modules/blog/controllers/PostController.php
View file @
c9eeb2d5
...
...
@@ -7,6 +7,7 @@ use common\components\BaseController;
use
yii\web\NotFoundHttpException
;
use
common\modules\blog\models\Post
;
use
common\modules\blog\models\PostTag
;
/**
* PostController implements the CRUD actions for Post model.
...
...
@@ -17,6 +18,7 @@ class PostController extends BaseController
{
return
[
'Index'
=>
'Блог'
,
'Tag'
=>
'Просмотр тега'
,
'View'
=>
'Просмотр записи'
,
];
}
...
...
@@ -36,6 +38,25 @@ class PostController extends BaseController
]);
}
/**
* Displays a single Post model.
* @param string $url
* @return mixed
*/
public
function
actionTag
(
$tag
)
{
$model
=
PostTag
::
find
()
->
where
([
'name'
=>
$tag
])
->
one
();
if
(
!
$model
||
!
$model
->
posts
)
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
return
$this
->
render
(
'tag'
,
[
'model'
=>
$model
,
]);
}
/**
* Displays a single Post model.
* @param string $url
...
...
common/modules/blog/models/PostTag.php
View file @
c9eeb2d5
...
...
@@ -4,6 +4,8 @@ namespace common\modules\blog\models;
use
Yii
;
use
yii\helpers\Url
;
use
common\modules\blog\models\Post
;
use
common\modules\blog\models\PostTagAssign
;
...
...
@@ -73,4 +75,9 @@ class PostTag extends \common\components\ActiveRecordModel
{
return
$this
->
hasMany
(
PostTagAssign
::
className
(),
[
'tag_id'
=>
'id'
]);
}
public
function
getUrl
()
{
return
Url
::
to
([
'/blog/tag/'
.
$this
->
name
]);
}
}
common/modules/blog/views/post/_sidebar.php
View file @
c9eeb2d5
...
...
@@ -22,7 +22,7 @@ use common\models\Settings;
->
all
();
foreach
(
$tags
as
$tag
)
:
?>
<a
href=
"
#
"
class=
"cat_link_mod"
>
<?=
$tag
->
name
?>
</a>
<a
href=
"
<?=
$tag
->
url
;
?>
"
class=
"cat_link_mod"
>
<?=
$tag
->
name
?>
</a>
<?php
endforeach
;
?>
...
...
common/modules/blog/views/post/index.php
View file @
c9eeb2d5
...
...
@@ -40,7 +40,7 @@ use yii\helpers\Url;
<?php
foreach
(
$model
->
postTags
as
$tag
)
:
?>
<a
href=
"
#
"
>
#
<?=
$tag
->
name
?>
</a>
<a
href=
"
<?=
$tag
->
url
;
?>
"
>
#
<?=
$tag
->
name
?>
</a>
<?php
endforeach
;
?>
...
...
common/modules/blog/views/post/tag.php
0 → 100644
View file @
c9eeb2d5
<?php
use
yii\helpers\Html
;
use
yii\helpers\Url
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
?>
<div
class=
"blog_container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-8 col-xs-8 col-sm-12"
>
<section
class=
"blog"
>
<h1>
<?=
Yii
::
t
(
'app'
,
'Tag'
)
?>
:
<?=
$model
->
name
;
?>
</h1>
<?php
foreach
(
$model
->
posts
as
$post
)
:
?>
<article
class=
"article_short"
>
<a
href=
"
<?=
Url
::
to
([
'/blog/'
.
$post
->
url
])
?>
"
class=
"article_short_title"
>
<?=
$post
->
lang
->
title
?>
</a>
<div
class=
"article_short_head"
>
<span
class=
"article_short_date"
>
<?=
date
(
'd.m.Y'
,
$post
->
created_at
)
?>
</span>
<!-- <span class="article_short_view">
180
<div class="blog_toltip_left">Количество просмотров</div>
</span> -->
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
</div>
<div
class=
"article_short_tags"
>
<?php
foreach
(
$post
->
postTags
as
$tag
)
:
?>
<a
href=
"
<?=
$tag
->
url
;
?>
"
>
#
<?=
$tag
->
name
?>
</a>
<?php
endforeach
;
?>
</div>
<div
class=
"article_short_txt"
>
<?php
if
(
$post
->
preview
)
:
echo
Html
::
img
(
$post
->
preview
);
endif
;
?>
<?=
$post
->
lang
->
text
?>
</div>
</article>
<?php
endforeach
;
?>
<?=
$this
->
render
(
'_subscribe'
)
?>
</section>
</div>
<?=
$this
->
render
(
'_sidebar'
)
?>
</div>
</div>
</div>
<div
class=
"end_keys_neft"
></div>
<?=
$this
->
render
(
'@app/views/layouts/footer'
);
?>
\ No newline at end of file
common/modules/blog/views/post/view.php
View file @
c9eeb2d5
...
...
@@ -35,7 +35,7 @@ use yii\helpers\Html;
<?php
foreach
(
$model
->
postTags
as
$tag
)
:
?>
<a
href=
"
#
"
>
#
<?=
$tag
->
name
?>
</a>
<a
href=
"
<?=
$tag
->
url
;
?>
"
>
#
<?=
$tag
->
name
?>
</a>
<?php
endforeach
;
?>
...
...
frontend/config/main.php
View file @
c9eeb2d5
...
...
@@ -154,6 +154,7 @@ return [
'faq/<url>'
=>
'faq/faq/view'
,
'faq'
=>
'faq/faq/index'
,
'blog'
=>
'blog/post/index'
,
'blog/tag/<tag>'
=>
'blog/post/tag'
,
'blog/<url>'
=>
'blog/post/view'
,
'school'
=>
'school/course/index'
,
'school/course/<id>'
=>
'school/course/view'
,
...
...
frontend/messages/ru-RU/app.php
View file @
c9eeb2d5
<?php
return
[
'Request a call'
=>
'Заказать звонок'
,
'Tag'
=>
'Тег'
];
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment