3108 - Важно - удаление лишних разделов из sitemao.xml

parent 58fc495f
<?php
use yii\db\Migration;
/**
* Class m190403_124144_fix_url
*/
class m190403_124144_fix_url extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('doc_content', 'url', $this->string(255)->notNull()->after('list_id'));
$docs = (new \yii\db\Query())
->from('doc_content_lang')
->select(['content_id', 'url'])
->groupBy(['content_id'])
->all();
foreach ($docs as $doc) {
$this->update('doc_content', ['url' => $doc['url']], ['id' => $doc['content_id']]);
}
$this->dropColumn('doc_content_lang', 'url');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->addColumn('doc_content_lang', 'url', $this->string(255)->after('lang_id'));
$docs = (new \yii\db\Query())
->from('doc_content')
->select(['id', 'url'])
->all();
foreach ($docs as $doc) {
$this->update('doc_content_lang', ['url' => $doc['url']], ['content_id' => $doc['id']]);
}
$this->dropColumn('doc_content', 'url');
}
}
<?php
use yii\db\Migration;
/**
* Class m190403_125033_add_fields
*/
class m190403_125033_add_fields extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('doc_content', 'created_at', $this->integer(11));
$this->addColumn('doc_content', 'updated_at', $this->integer(11));
$this->update('doc_content', ['created_at' => time(), 'updated_at' => time()]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('doc_content', 'created_at');
$this->dropColumn('doc_content', 'updated_at');
}
}
...@@ -13,6 +13,7 @@ use common\models\MetaTags; ...@@ -13,6 +13,7 @@ use common\models\MetaTags;
* *
* @property int $id * @property int $id
* @property int $list_id * @property int $list_id
* @property string $url
* @property int $priority * @property int $priority
* *
* @property DocList $list * @property DocList $list
...@@ -47,22 +48,24 @@ class DocContent extends \yii\db\ActiveRecord ...@@ -47,22 +48,24 @@ class DocContent extends \yii\db\ActiveRecord
'langClass' => 'common\modules\documentation\models\DocContentLang', 'langClass' => 'common\modules\documentation\models\DocContentLang',
'actions' => ['create', 'update'] 'actions' => ['create', 'update']
], ],
// 'sitemap' => [ 'Timestamp' => [
// 'class' => SitemapBehavior::className(), 'class' => '\yii\behaviors\TimestampBehavior',
// 'scope' => function ($model) { ],
// /** @var \yii\db\ActiveQuery $model */ 'sitemap' => [
// $model->select(['url', 'updated_at', 'priority']); 'class' => SitemapBehavior::className(),
// $model->andWhere(['active' => 1]); 'scope' => function ($model) {
// }, /** @var \yii\db\ActiveQuery $model */
// 'dataClosure' => function ($model) { $model->select(['url', 'updated_at', 'priority']);
// return [ },
// 'loc' => Url::to($model->url), 'dataClosure' => function ($model) {
// 'lastmod' => date('c', $model->updated_at), return [
// 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'loc' => Url::to($model->url),
// 'priority' => $model->priority 'lastmod' => date('c', $model->updated_at),
// ]; 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
// } 'priority' => $model->priority
// ], ];
}
],
]; ];
} }
/** /**
...@@ -71,9 +74,9 @@ class DocContent extends \yii\db\ActiveRecord ...@@ -71,9 +74,9 @@ class DocContent extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['list_id','priority'], 'required'], [['list_id', 'priority', 'url'], 'required'],
[['list_id'], 'integer'], [['list_id', 'created_at', 'updated_at'], 'integer'],
[[ 'priority'], 'number'], [['priority'], 'number'],
[['list_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocList::className(), 'targetAttribute' => ['list_id' => 'id']], [['list_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocList::className(), 'targetAttribute' => ['list_id' => 'id']],
]; ];
} }
......
...@@ -39,7 +39,7 @@ class DocContentLang extends \yii\db\ActiveRecord ...@@ -39,7 +39,7 @@ class DocContentLang extends \yii\db\ActiveRecord
[['content_id', 'lang_id'], 'required'], [['content_id', 'lang_id'], 'required'],
[['content_id', 'lang_id'], 'integer'], [['content_id', 'lang_id'], 'integer'],
[['markdown', 'html'], 'string'], [['markdown', 'html'], 'string'],
[['url', 'name'], 'string', 'max' => 255], [['name'], 'string', 'max' => 255],
[['content_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocContent::className(), 'targetAttribute' => ['content_id' => 'id']], [['content_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocContent::className(), 'targetAttribute' => ['content_id' => 'id']],
[['lang_id'], 'exist', 'skipOnError' => true, 'targetClass' => Languages::className(), 'targetAttribute' => ['lang_id' => 'id']], [['lang_id'], 'exist', 'skipOnError' => true, 'targetClass' => Languages::className(), 'targetAttribute' => ['lang_id' => 'id']],
]; ];
...@@ -55,7 +55,6 @@ class DocContentLang extends \yii\db\ActiveRecord ...@@ -55,7 +55,6 @@ class DocContentLang extends \yii\db\ActiveRecord
'content_id' => 'Content ID', 'content_id' => 'Content ID',
'lang_id' => 'Lang ID', 'lang_id' => 'Lang ID',
'name' => 'Заголовок', 'name' => 'Заголовок',
'url' => 'Ссылка',
'markdown' => 'Markdown', 'markdown' => 'Markdown',
'html' => 'Html', 'html' => 'Html',
]; ];
......
...@@ -32,6 +32,14 @@ $defaultUrl = ( ...@@ -32,6 +32,14 @@ $defaultUrl = (
]); ]);
?> ?>
<?php
if ($defaultUrl) {
echo $form->field($documentation, 'url')->textInput(['value' => $defaultUrl, 'readonly' => 'readonly', 'maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html');
} else {
echo $form->field($documentation, 'url')->textInput(['maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html');
}
?>
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<?php <?php
...@@ -52,14 +60,6 @@ $defaultUrl = ( ...@@ -52,14 +60,6 @@ $defaultUrl = (
<?= $form->field($documentation, '[' . $lang_id . ']name')->textInput(['maxlength' => 250])->hint('Заголовок страницы виден пользователю сайта и как правило оформляется в тег &lt;h1&gt;.') ?> <?= $form->field($documentation, '[' . $lang_id . ']name')->textInput(['maxlength' => 250])->hint('Заголовок страницы виден пользователю сайта и как правило оформляется в тег &lt;h1&gt;.') ?>
<?php
if ($defaultUrl) {
echo $form->field($documentation, '[' . $lang_id . ']url')->textInput(['value' => $defaultUrl, 'readonly' => 'readonly', 'maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html');
} else {
echo $form->field($documentation, '[' . $lang_id . ']url')->textInput(['maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html');
}
?>
<div id="documentation-editormd_<?= $lang_id ?>" class="documentation-editormd" data-id="<?= $lang_id ?>"> <div id="documentation-editormd_<?= $lang_id ?>" class="documentation-editormd" data-id="<?= $lang_id ?>">
</div> </div>
<div class="documentation-editormd_<?= $lang_id ?> hidden" style="display:none"> <div class="documentation-editormd_<?= $lang_id ?> hidden" style="display:none">
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace common\modules\faq\models; namespace common\modules\faq\models;
use frontend\modules\sitemap\behaviors\SitemapBehavior;
use Yii; use Yii;
use yii\helpers\Url; use yii\helpers\Url;
...@@ -91,20 +92,25 @@ class Faq extends \common\components\ActiveRecordModel ...@@ -91,20 +92,25 @@ class Faq extends \common\components\ActiveRecordModel
'langClass' => 'common\modules\faq\models\FaqContentLang', 'langClass' => 'common\modules\faq\models\FaqContentLang',
'actions' => ['create', 'update', 'copy'] 'actions' => ['create', 'update', 'copy']
], ],
// 'tags' => [
// 'class' => 'common\modules\blog\components\TagBehavior',
// ],
'Timestamp' => [ 'Timestamp' => [
'class' => '\yii\behaviors\TimestampBehavior', 'class' => '\yii\behaviors\TimestampBehavior',
], ],
// 'file' => [ 'sitemap' => [
// 'class' => 'common\components\activeRecordBehaviors\FileUploadBehavior', 'class' => SitemapBehavior::className(),
// 'thumb' => true, 'scope' => function ($model) {
// 'thumbSize' => ['280', '141'], /** @var \yii\db\ActiveQuery $model */
// 'path' => '@frontend/web', $model->select(['url', 'updated_at']);
// 'folder' => '/uploads/faq/', $model->andWhere(['active' => 1]);
// 'field' => 'preview' },
// ], 'dataClosure' => function ($model) {
return [
'loc' => "faq/{$model->url}",
'lastmod' => date('c', $model->updated_at),
'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.5
];
}
],
]; ];
} }
......
...@@ -30,24 +30,26 @@ return [ ...@@ -30,24 +30,26 @@ return [
'sitemap' => [ 'sitemap' => [
'class' => 'frontend\modules\sitemap\Sitemap', 'class' => 'frontend\modules\sitemap\Sitemap',
'models' => [ 'models' => [
// your models
'common\modules\content\models\CoContent', 'common\modules\content\models\CoContent',
'common\modules\blog\models\Post', 'common\modules\blog\models\Post',
// 'common\modules\documentation\models\***'], 'common\modules\faq\models\Faq'
], ],
'urls' => [ 'urls' => [
// // your additional urls [
// [ 'loc' => 'platforma-taskon',
// 'loc' => '/faq', 'changefreq' => frontend\modules\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
// 'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8,
// 'priority' => 0.8, ],
// 'faq' => [ [
// 'publication' => [ 'loc' => 'faq-video',
// 'name' => 'Вопрос-Ответ', 'changefreq' => frontend\modules\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
// 'language' => 'ru', 'priority' => 0.6,
// ], ],
// ], [
// ], 'loc' => 'contacts',
'changefreq' => frontend\modules\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.6,
],
], ],
'enableGzip' => true, // default is false 'enableGzip' => true, // default is false
'cacheExpire' => 1, // 1 second. Default is 24 hours 'cacheExpire' => 1, // 1 second. Default is 24 hours
......
...@@ -92,7 +92,7 @@ class SiteController extends FrontendController ...@@ -92,7 +92,7 @@ class SiteController extends FrontendController
$this->meta_title = $model->metaTag->title; $this->meta_title = $model->metaTag->title;
$this->meta_description = $model->metaTag->description; $this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords; $this->meta_keywords = $model->metaTag->keywords;
Yii::$app->response->statusCode = 404; Yii::$app->response->setStatusCode(404);
return $this->render('error', ['content'=>$content]); return $this->render('error', ['content'=>$content]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment