From 28bee24bf3f4d1272db7e399165fac3f001f5829 Mon Sep 17 00:00:00 2001 From: Nelya-home Date: Sun, 9 Feb 2020 20:40:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B?= =?UTF-8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA.=20=D0=A0=D0=B5=D0=B4?= =?UTF-8?q?=D0=B8=D1=80=D0=B5=D0=BA=D1=82=20=D0=BD=D0=B0=20=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D1=83=D1=8E=20=D0=B8=D0=BB=D0=B8=20404.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CmsSeoComponent.php | 13 +++++++++++-- src/messages/ru/main.php | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CmsSeoComponent.php b/src/CmsSeoComponent.php index ab67da5..e3318bb 100644 --- a/src/CmsSeoComponent.php +++ b/src/CmsSeoComponent.php @@ -165,6 +165,10 @@ class CmsSeoComponent extends Component implements BootstrapInterface */ public $isRedirectNotFoundHttpException = true; + /** + * @var bool + */ + public $enableErrorPage=false; /** * Можно задать название и описание компонента @@ -180,7 +184,7 @@ static public function descriptorConfig() public function rules() { return ArrayHelper::merge(parent::rules(), [ - [['enableKeywordsGenerator', 'minKeywordLenth', 'maxKeywordsLength', 'activeContentElem', 'activeTree'], 'integer'], + [['enableKeywordsGenerator', 'minKeywordLenth', 'maxKeywordsLength', 'activeContentElem', 'activeTree', 'enableErrorPage'], 'integer'], ['robotsContent', 'string'], ['countersContent', 'string'], [['contentIds', 'treeTypeIds'], 'safe'], @@ -201,6 +205,7 @@ public function attributeLabels() 'contentIds' => \Yii::t('skeeks/cms', 'Elements of content'), 'sitemap_min_date' => \Yii::t('skeeks/seo', 'Минимальная дата обновления ссылки'), 'treeTypeIds' => \Yii::t('skeeks/seo', 'Types of tree'), + 'enableErrorPage' => \Yii::t('skeeks/seo', 'Show 404 page'), ]); } @@ -217,6 +222,7 @@ public function attributeHints() 'treeTypeIds' => \Yii::t('skeeks/seo', 'If nothing is selected, then all'), 'sitemap_min_date' => \Yii::t('skeeks/seo', 'Если будет задан этот параметр, то ни в одной ссылке не будет указано даты обновления меньше этой. Используется для переиндексации всех страниц.'), + 'enableErrorPage' => \Yii::t('skeeks/seo', 'If nothing is selected, then error page redirect to homepage'), ]); } @@ -260,6 +266,9 @@ public function renderConfigFormFields(ActiveForm $form) 'type' => \kartik\datecontrol\DateControl::FORMAT_DATE, ]); + $result .= $form->fieldSetEnd(); + $result .= $form->fieldSet(\Yii::t('skeeks/seo', 'Error page')); + $result .= $form->field($this, 'enableErrorPage')->checkbox(\Yii::$app->formatter->booleanFormat); $result .= $form->fieldSetEnd(); return $result; @@ -372,7 +381,7 @@ public function bootstrap($application) * Редирект 404 ошибок */ if (\Yii::$app->controller->uniqueId == 'cms/error') { - if (\Yii::$app->getErrorHandler()->exception instanceof NotFoundHttpException && $this->isRedirectNotFoundHttpException && !BackendComponent::getCurrent()) { + if (\Yii::$app->getErrorHandler()->exception instanceof NotFoundHttpException && $this->isRedirectNotFoundHttpException && !BackendComponent::getCurrent() && !\Yii::$app->seo->enableErrorPage) { \Yii::$app->response->redirect(Url::home()); \Yii::$app->response->getHeaders()->setDefault('X-Skeeks-Seo-Not-Found', "isRedirectNotFoundHttpException=true"); \Yii::$app->end(); diff --git a/src/messages/ru/main.php b/src/messages/ru/main.php index a24a2dc..4928ed5 100644 --- a/src/messages/ru/main.php +++ b/src/messages/ru/main.php @@ -6,6 +6,9 @@ 'Indexing' => 'Индексация', 'Codes counters' => 'Коды счетчиков', 'Sitemap settings' => 'Карта сайта', + 'Error page' => '404 страница', + 'Show 404 page' => 'Показывать 404 страницу', + 'If nothing is selected, then error page redirect to homepage' => 'Если галочки нет, несуществующие страницы перекидывают на главную страницу сайта', 'Types of tree' => 'Укажите типы разделов', 'Active flag to contents element' => 'Учитывать флаг активности для элементов контента', 'Active flag to tree' => 'Учитывать флаг активности для разделов',