andrewdanilov / yii2-sitemap
组件可为您模型的模型、控制器动作或随机页面生成sitemap.xml。
1.0.0
2019-04-16 12:37 UTC
Requires
- php: >=5.6.0
- ext-dom: *
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-16 23:24:46 UTC
README
组件可为您模型的模型、控制器动作或随机页面生成sitemap.xml。
安装
安装此扩展的首选方法是通过 composer。
运行以下命令之一
composer require andrewdanilov/yii2-sitemap "~1.0.0"
或将以下内容添加到您的 composer.json
文件的 require 部分中。
"andrewdanilov/yii2-sitemap": "~1.0.0"
用法
将组件 Sitemap 添加到主配置文件中
return [ ... 'components' => [ ... 'sitemap' => [ 'class' => andrewdanilov\sitemap\Sitemap, 'urls' => [ // Full notation for ActiveRecord model. // All found records will be collected for building sitemap. [ 'class' => 'frontend\models\Products', 'url' => ['catalog/product'], 'attribute' => 'id', // optional 'changeFreq' => andrewdanilov\sitemap\LocParams::WEEKLY, // optional 'priority' => 0.1, // optional 'lastMod' => 0, // optional ], // Full notation for single url/action. [ 'url' => ['catalog/index'], 'changeFreq' => andrewdanilov\sitemap\LocParams::WEEKLY, // optional 'priority' => 0.1, // optional 'lastMod' => 0, // optional ], // Short notation for single url/action ['catalog/index'], // Short notation for single random url 'category1/product123?page=2', ], ], ], ];