From 14c89ea2d0a881a279adcb32648bd4c0519c277f Mon Sep 17 00:00:00 2001 From: Anastasia Date: Thu, 2 Aug 2018 12:57:19 +0300 Subject: [PATCH] seo --- common/config/main.php | 2 +- frontend/components/SeoComponent.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ frontend/config/main.php | 2 +- frontend/views/layouts/main.php | 7 +++++++ frontend/views/support/index.php | 9 +++++++-- 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 frontend/components/SeoComponent.php diff --git a/common/config/main.php b/common/config/main.php index efd2a4d..ab8b501 100644 --- a/common/config/main.php +++ b/common/config/main.php @@ -1,6 +1,6 @@ controller->id, $this->close)){ + return 'noindex, nofollow'; + } + if (array_search(\Yii::$app->request->pathInfo, $this->close)){ + return 'noindex, nofollow'; + } + + if (!empty($this->robots)) { + return $this->robots; + } + + if (!empty($this->alias) && !empty($this->alias->getRobots())) { + return $this->alias->getRobots(); + } + + return 'index,follow'; + } + + } \ No newline at end of file diff --git a/frontend/config/main.php b/frontend/config/main.php index 88db717..2271211 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -1,5 +1,5 @@ registerJs($js, View::POS_READY); } + + $this->registerMetaTag( + [ + 'name' => 'robots', + 'content' => $seo->robots, + ] + ); ?> beginPage() ?> diff --git a/frontend/views/support/index.php b/frontend/views/support/index.php index e9a43be..ee09a5a 100644 --- a/frontend/views/support/index.php +++ b/frontend/views/support/index.php @@ -2,10 +2,15 @@ /** * @var \common\models\Book $book * @var \common\models\Support $model + * @var \artbox\core\components\SeoComponent $seo */ - use yii\helpers\Html; + use artbox\core\models\Alias;use yii\helpers\Html; use yii\widgets\ActiveForm; - + $seo = \Yii::$app->get('seo'); + + $seo->setAlias(new Alias([ + 'title' => 'Підтримати книгу "'.$book->title.'"' + ])); ?>
-- libgit2 0.21.4