Skip to content

Commit 88afc57

Browse files
sitemap_min_date
1 parent dd39721 commit 88afc57

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
==============
33

4+
2.1.5
5+
-----------------
6+
* sitemap_min_date
7+
48
2.1.4
59
-----------------
610
* Dynamic canurl params by ListView or GridView

src/CmsSeoComponent.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ class CmsSeoComponent extends Component implements BootstrapInterface
7777
* @var string
7878
*/
7979
public $activeContentElem = true;
80+
81+
/**
82+
* @var int
83+
*/
84+
public $sitemap_min_date;
85+
8086
/**
8187
* @var string
8288
*/
@@ -147,6 +153,7 @@ public function rules()
147153
['robotsContent', 'string'],
148154
['countersContent', 'string'],
149155
[['contentIds', 'treeTypeIds'], 'safe'],
156+
['sitemap_min_date', 'integer'],
150157
]);
151158
}
152159

@@ -161,6 +168,7 @@ public function attributeLabels()
161168
'activeTree' => \Yii::t('skeeks/seo', 'Active flag to tree'),
162169
'activeContentElem' => \Yii::t('skeeks/seo', 'Active flag to contents element'),
163170
'contentIds' => \Yii::t('skeeks/cms', 'Elements of content'),
171+
'sitemap_min_date' => \Yii::t('skeeks/seo', 'Минимальная дата обновления ссылки'),
164172
'treeTypeIds' => \Yii::t('skeeks/seo', 'Types of tree'),
165173
]);
166174
}
@@ -174,6 +182,9 @@ public function attributeHints()
174182
'robotsContent' => \Yii::t('skeeks/seo', 'This value is added to the automatically generated file robots.txt, in the case where it is not physically created on the server'),
175183
'contentIds' => \Yii::t('skeeks/seo', 'If nothing is selected, then all'),
176184
'treeTypeIds' => \Yii::t('skeeks/seo', 'If nothing is selected, then all'),
185+
'sitemap_min_date' => \Yii::t('skeeks/exportShopYandexMarket',
186+
'Если будет задан этот параметр, то ни в одной ссылке не будет указано даты обновления меньше этой. Используется для переиндексации всех страниц.'),
187+
177188
]);
178189
}
179190

@@ -202,6 +213,7 @@ public function renderConfigForm(ActiveForm $form)
202213
echo $form->field($this, 'activeContentElem')->checkbox(\Yii::$app->formatter->booleanFormat);
203214
echo $form->field($this, 'activeTree')->checkbox(\Yii::$app->formatter->booleanFormat);
204215

216+
205217
echo $form->fieldSelectMulti($this, 'contentIds', \skeeks\cms\models\CmsContent::getDataForSelect());
206218
/*echo $form->fieldSelectMulti($this, 'createdBy')->widget(
207219
\skeeks\cms\modules\admin\widgets\formInputs\SelectModelDialogUserInput::className()
@@ -210,6 +222,11 @@ public function renderConfigForm(ActiveForm $form)
210222
echo $form->fieldSelectMulti($this, 'treeTypeIds', \yii\helpers\ArrayHelper::map(
211223
\skeeks\cms\models\CmsTreeType::find()->all(), 'id', 'name'
212224
));
225+
226+
echo $form->field($this, 'sitemap_min_date')->widget(\kartik\datecontrol\DateControl::classname(), [
227+
'type' => \kartik\datecontrol\DateControl::FORMAT_DATETIME,
228+
]);
229+
213230
echo $form->fieldSetEnd();
214231

215232
}

src/controllers/SitemapController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ protected function _addTrees(&$data = [])
8686
*/
8787
private function _lastMod($model)
8888
{
89-
$string = "2013-08-03T21:14:41+01:00";
90-
$string = date("Y-m-d", $model->updated_at) . "T" . date("H:i:s+03:00", $model->updated_at);
89+
$string = date("c", $model->updated_at);
90+
91+
if (\Yii::$app->seo->sitemap_min_date && \Yii::$app->seo->sitemap_min_date > $model->updated_at) {
92+
$string = date("c", \Yii::$app->seo->sitemap_min_date);
93+
}
9194

9295
return $string;
9396
}

0 commit comments

Comments
 (0)