Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/CmsSeoComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ class CmsSeoComponent extends Component implements BootstrapInterface
*/
public $isRedirectNotFoundHttpException = true;

/**
* @var bool
*/
public $enableErrorPage=false;

/**
* Можно задать название и описание компонента
Expand All @@ -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'],
Expand All @@ -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'),
]);
}

Expand All @@ -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'),

]);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/messages/ru/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => 'Учитывать флаг активности для разделов',
Expand Down