/** * @inheritdoc */ public function behaviors() { return \yii\helpers\ArrayHelper::merge(parent::behaviors(), ['translateable' => ['class' => \creocoder\translateable\TranslateableBehavior::className(), 'translationAttributes' => static::getTranslationAttributes()], 'timestamp' => ['class' => \yii\behaviors\TimestampBehavior::className()], 'sitemap' => ['class' => SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->andWhere(['published' => 1]); }, 'dataClosure' => function ($model) { /** @var self $model */ return ['loc' => Url::to($model->getViewUrl(), true), 'lastmod' => $model->updated_at, 'changefreq' => SitemapBehavior::CHANGEFREQ_WEEKLY, 'priority' => 0.8]; }]]); }
public function behaviors() { return ['sitemap' => ['class' => SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->andWhere(['status' => 'done']); }, 'dataClosure' => function ($model) { /** @var self $model */ return ['loc' => $model->getLink(), 'lastmod' => strtotime($model->updated_at), 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8]; }]]; }
/** * @inheritdoc */ public function behaviors() { return ['sitemap' => ['class' => \himiklab\sitemap\behaviors\SitemapBehavior::className(), 'scope' => function ($model) { // @var \yii\db\ActiveQuery $model $model->select(['slug', 'updated_at']); $model->andWhere(['status' => 1]); $model->andWhere(['locale' => 'uk-UA']); }, 'dataClosure' => function ($model) { // @var self $model return ['loc' => \yii\helpers\Url::to('uk/article/' . $model->slug, true), 'lastmod' => $model->updated_at, 'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8]; }]]; }
<?php $params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'); return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'timeZone' => 'EET', 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'urlManager' => ['enablePrettyUrl' => true, 'enableStrictParsing' => false, 'showScriptName' => false, 'rules' => ['category/<slug:\\w+>' => 'category/index', 'news/<id:\\d+>/<title:[^$]*>' => 'news/index', ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'], 'defaultRoute' => 'site/index']], 'cache' => ['class' => 'yii\\caching\\FileCache']], 'modules' => ['sitemap' => ['class' => 'himiklab\\sitemap\\Sitemap', 'models' => ['common\\models\\News', ['class' => 'common\\models\\News', 'behaviors' => ['sitemap' => ['class' => \himiklab\sitemap\behaviors\SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->andWhere(['status' => 'done']); }, 'dataClosure' => function ($model) { /** @var self $model */ return ['loc' => $model->getLink(), 'lastmod' => strtotime($model->updated_at), 'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8]; }]]]], 'urls' => [['loc' => '/', 'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8, 'news' => ['publication' => ['name' => 'Агрегатор новостей', 'language' => 'ru'], 'access' => 'Subscription', 'genres' => 'новости', 'publication_date' => 'YYYY-MM-DDThh:mm:ssTZD', 'title' => 'Агрегатор новостей', 'keywords' => 'новости, свежие новости, новости украины, новости сегодня, агрегатор новостей', 'stock_tickers' => 'NASDAQ:A, NASDAQ:B'], 'images' => [['loc' => 'http://nagg.in.ua/', 'caption' => 'Агрегатор новостей', 'geo_location' => 'Украина', 'title' => 'Агрегатор новостей Украина']]]], 'enableGzip' => true, 'cacheExpire' => 1]], 'params' => $params];
<?php use common\helpers\Time; use himiklab\sitemap\behaviors\SitemapBehavior; use nodge\eauth\services\GoogleOAuth2Service; $params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'); return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'language' => 'ru_RU', 'bootstrap' => ['log'], 'name' => 'findspree', 'controllerNamespace' => 'frontend\\controllers', 'modules' => ['sitemap' => ['class' => 'himiklab\\sitemap\\Sitemap', 'models' => [['class' => \common\models\Event::className(), 'behaviors' => ['sitemap' => ['class' => SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->select(['id', 'created_at', 'updated']); return $model->where(['>', 'begin', time() - Time::SEC_TO_MONTH]); }, 'dataClosure' => function ($model) { /** @var \common\models\Event $model */ return ['loc' => \yii\helpers\Url::to(['/event/view', 'id' => $model->id], true), 'lastmod' => $model->updated ?: $model->created_at, 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => $model->begin > time() ? 1 : 0.5]; }]]]], 'enableGzip' => true, 'cacheExpire' => Time::SEC_TO_HOUR]], 'components' => ['i18n' => ['translations' => ['eauth' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@eauth/messages']]], 'user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'urlManager' => ['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['events' => '/site/index', 'map' => 'event/map', 'user<id:\\d+>' => 'user/index', 'my' => 'user/index', 'event<id:\\d+>' => 'event/view', ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml']]], 'errorHandler' => ['errorAction' => 'site/error'], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'request' => ['class' => \common\component\Request::className()], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'viewPath' => '@app/mail', 'htmlLayout' => 'layouts/html', 'useFileTransport' => false, 'transport' => ['class' => 'Swift_SmtpTransport', 'host' => 'smtp.yandex.ru', 'username' => '*****@*****.**', 'password' => 'eu6na012', 'port' => '465', 'encryption' => 'ssl']]], 'params' => $params];