Skip to content

Commit cfa62dc

Browse files
SEO доработки
1 parent ae9a413 commit cfa62dc

3 files changed

Lines changed: 46 additions & 8 deletions

File tree

src/CmsSeoComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ public function getConfigFormFields()
373373
'class' => BoolField::class,
374374
'allowNull' => false,
375375
],
376-
'activeContentElem' => [
376+
/*'activeContentElem' => [
377377
'class' => BoolField::class,
378378
'allowNull' => false,
379379
],
380380
'activeTree' => [
381381
'class' => BoolField::class,
382382
'allowNull' => false,
383-
],
383+
],*/
384384
'contentIds' => [
385385
'class' => SelectField::class,
386386
'items' => \skeeks\cms\models\CmsContent::getDataForSelect(),

src/controllers/SitemapController.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,45 @@ public function actionOnRequest()
5050
protected function _addTrees(&$data = [])
5151
{
5252
$query = CmsTree::find()->cmsSite();
53+
$query->andWhere([
54+
'and',
55+
[
56+
'redirect_tree_id' => null,
57+
],
58+
[
59+
'redirect_content_element_id' => null,
60+
],
61+
[
62+
'redirect_saved_filter_id' => null,
63+
],
64+
[
65+
'or',
66+
['redirect' => null],
67+
['redirect' => ""]
68+
]
69+
]);
5370

54-
if (\Yii::$app->seo->activeTree) {
55-
$query->active();
56-
}
71+
$query->andWhere([
72+
'and',
73+
[
74+
'canonical_tree_id' => null,
75+
],
76+
[
77+
'canonical_content_element_id' => null,
78+
],
79+
[
80+
'canonical_saved_filter_id' => null,
81+
],
82+
[
83+
'or',
84+
['canonical_link' => null],
85+
['canonical_link' => ""]
86+
]
87+
]);
88+
89+
$query->andWhere([
90+
'is_index' => 1,
91+
]);
5792

5893
if (\Yii::$app->seo->treeTypeIds) {
5994
$query->andWhere(['tree_type_id' => \Yii::$app->seo->treeTypeIds]);
@@ -66,7 +101,7 @@ protected function _addTrees(&$data = [])
66101
* @var Tree $tree
67102
*/
68103
foreach ($trees as $tree) {
69-
if (!$tree->redirect && !$tree->redirect_tree_id) {
104+
//if (!$tree->redirect && !$tree->redirect_tree_id) {
70105
$tmp = [
71106
"loc" => $tree->absoluteUrl,
72107
"lastmod" => $this->_lastMod($tree),
@@ -77,7 +112,7 @@ protected function _addTrees(&$data = [])
77112
}
78113

79114
$data[] = $tmp;
80-
}
115+
//}
81116
}
82117
}
83118

src/vendor/CanUrl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ public function event_end_page(Event $event)
119119
/** @var \yii\web\View $view */
120120
$view = $event->sender;
121121
if (!\Yii::$app->request->isPjax && !\Yii::$app->request->isAjax) {
122-
$view->linkTags['canonical'] = '<link rel="canonical" href="'.$canurl.'"/>';
122+
if (!isset($view->linkTags['canonical'])) {
123+
$view->linkTags['canonical'] = '<link rel="canonical" href="'.$canurl.'"/>';
124+
}
125+
123126
}
124127

125128

0 commit comments

Comments
 (0)