Commit 14c89ea2d0a881a279adcb32648bd4c0519c277f
1 parent
a90233d1
seo
Showing
5 changed files
with
62 additions
and
4 deletions
Show diff stats
common/config/main.php
1 | +<?php | |
2 | + /** | |
3 | + * Created by PhpStorm. | |
4 | + * User: stes | |
5 | + * Date: 02.08.18 | |
6 | + * Time: 12:41 | |
7 | + */ | |
8 | + | |
9 | + namespace frontend\components; | |
10 | + | |
11 | + class SeoComponent extends \artbox\core\components\SeoComponent | |
12 | + { | |
13 | + /** | |
14 | + * @todo Refactor later for sorting and pagination | |
15 | + * @return string | |
16 | + */ | |
17 | + public $close = [ | |
18 | + 'support', | |
19 | + 'author', | |
20 | + 'book/add', | |
21 | + 'book/success', | |
22 | + 'site/login', | |
23 | + 'site/register' | |
24 | + ]; | |
25 | + | |
26 | + public function getRobots() | |
27 | + { | |
28 | + if (array_search(\Yii::$app->controller->id, $this->close)){ | |
29 | + return 'noindex, nofollow'; | |
30 | + } | |
31 | + if (array_search(\Yii::$app->request->pathInfo, $this->close)){ | |
32 | + return 'noindex, nofollow'; | |
33 | + } | |
34 | + | |
35 | + if (!empty($this->robots)) { | |
36 | + return $this->robots; | |
37 | + } | |
38 | + | |
39 | + if (!empty($this->alias) && !empty($this->alias->getRobots())) { | |
40 | + return $this->alias->getRobots(); | |
41 | + } | |
42 | + | |
43 | + return 'index,follow'; | |
44 | + } | |
45 | + | |
46 | + } | |
0 | 47 | \ No newline at end of file | ... | ... |
frontend/config/main.php
frontend/views/layouts/main.php
frontend/views/support/index.php
... | ... | @@ -2,10 +2,15 @@ |
2 | 2 | /** |
3 | 3 | * @var \common\models\Book $book |
4 | 4 | * @var \common\models\Support $model |
5 | + * @var \artbox\core\components\SeoComponent $seo | |
5 | 6 | */ |
6 | - use yii\helpers\Html; | |
7 | + use artbox\core\models\Alias;use yii\helpers\Html; | |
7 | 8 | use yii\widgets\ActiveForm; |
8 | - | |
9 | + $seo = \Yii::$app->get('seo'); | |
10 | + | |
11 | + $seo->setAlias(new Alias([ | |
12 | + 'title' => 'Підтримати книгу "'.$book->title.'"' | |
13 | + ])); | |
9 | 14 | ?> |
10 | 15 | <section class="section-books-support"> |
11 | 16 | <div class="container"> | ... | ... |