原 服务器搭建
|-摘 Yii2生成sitemap,yii2-sitemap-module Yii2 module for automatically generating XML Sitemap
两个都是Yii2的扩展https://www.yiiframework.com/extension/mubat/yii2-sitemap-generator mubat/yii2-s...
两个都是Yii2的扩展
https://www.yiiframework.com/extension/mubat/yii2-sitemap-generator
mubat/yii2-sitemap-generatorYii2 widget for sitemap generation
yii2-sitemap-generator
Simple widget forYii2 frameworkto generate sitemap.
SupportXMLformat generation.
Support multi language.
Installation
Composer
The preferred way to install this extension is throughComposer.
Either run`
php composer require mubat/yii2-sitemap-generator`
or add`
"mubat/yii2-sitemap-generator" : "~1.0"to the require section of your
composer.json`
Widget contains 2 models:
- Sitemap- base model. It containsSitemapElementarray and methods to generate XML. If
$languages
array published, model will generate'alternate'links. - SitemapElement- represents one
<url>
element. It contains:$loc
-requrired- page url (as array). Before insert into XML it will be process byyii2\helpers\Url::toRoute()
method.$updated_at
-optional- last page update;$changefreq
-requrired, default'weekly'
- from class constant.$priority
-requrired, default0.4
- page priority.
https://www.yiiframework.com/extension/yii2-sitemap-module
yii2-sitemap-moduleYii2 module for automatically generating XML Sitemap
Yii2 module for automatically generatingXML Sitemap.
Installation
The preferred way to install this extension is throughcomposer.
Either run
php composer.phar require --prefer-dist "himiklab/yii2-sitemap-module" "*"
or add
"himiklab/yii2-sitemap-module" : "*"
to the require section of your application'scomposer.json
file.
Usage
- Configure the
cache
component of your application's configuration file, for example:
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
]
- Add a new module in
modules
section of your application's configuration file, for example:
'modules' => [
'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap',
'models' => [
// your models
'app\modules\news\models\News',
],
'urls'=> [
// your additional urls
[
'loc' => '/news/index',
'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.8,
'news' => [
'publication' => [
'name' => 'Example Blog',
'language' => 'en',
],
'access' => 'Subscription',
'genres' => 'Blog, UserGenerated',
'publication_date' => 'YYYY-MM-DDThh:mm:ssTZD',
'title' => 'Example Title',
'keywords' => 'example, keywords, comma-separated',
'stock_tickers' => 'NASDAQ:A, NASDAQ:B',
],
'images' => [
[
'loc' => ,
'caption' => 'This is an example of a caption of an image',
'geo_location' => 'City, State',
'title' => 'Example image',
'license' => 'http://example.com/license',
],
],
],
],
'enableGzip' => true, // default is false
'cacheExpire' => 1, // 1 second. Default is 24 hours
],
],
- Add behavior in the AR models, for example:
use himiklab\sitemap\behaviors\SitemapBehavior;
public function behaviors()
{
return [
'sitemap' => [
'class' => SitemapBehavior::className(),
'scope' => function ($model) {
/** @var \yii\db\ActiveQuery $model */
$model->select(['url', 'lastmod']);
$model->andWhere(['is_deleted' => 0]);
},
'dataClosure' => function ($model) {
/** @var self $model */
return [
'loc' => Url::to($model->url, true),
'lastmod' => strtotime($model->lastmod),
'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.8
];
}
],
];
}
- Add a new rule for
urlManager
of your application's configuration file, for example:
'urlManager' => [
'rules' => [
['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],
],
],
Resources¶
更新于:2020-03-29 01:13:31
相关内容
Yii2小部件Widget
Widgets 小部件kop/yii2-scroll-pager:瀑布滚动翻页 样式不怎么好看,必须点击更多才能加载更多yii2-widget-linkpager...
Yii2模型简介
模型Model是MVC模型中的M,是业务数据、业务规则和业务逻辑的对象。Yii很好的展现了这点,用户可用创...
Yii2模型简介-属性
Yii2模型简介-场景
Yii2模型简介-验证规则
Yii2模型简介-块赋值
Yii2模型简介-非安全属性
Yii2模型简介-数据导出
Yii2模型简介-字段
Yii2模型简介-最佳实践
Yii2扩展整理
这里整理一些自己实测好用的Yii2扩展 20200406
【坑,勿用】Yii的yii-xunsearch扩展,支持中文的搜索引擎,
简单,易用的yii2导入和导出组件( illusion/yii2-excel)
Yii2 学习内容整理
Yii2片段缓存详解yii2常用表单处理方法php yii2 出现mysql-gone-away-2006解决Yii2 数据操作DAO【翻译】 MySQL中yii2使用...
Yii2片段缓存详解
yii2常用表单处理方法
php yii2 出现mysql-gone-away-2006解决
Yii2 数据操作DAO
【翻译】 MySQL中yii2使用原生sql CURD
一篇为你讲透Yii2的widget
Yii2模块学习
Yii2提交表单提示无法验证
解决Yii2 在线上服务器无法访问GII 和BUG工具栏问题
Yii2 Model的一些常用验证rules规则
关于Yii2控制器的layout属性
yii2如何开启debug工具栏
使用Yii2发送邮件
Yii2多表联结子查询的应用
学习yii2.0——数据缓存、片段缓存、页面缓存、http缓存
Yii2 获取模块名、控制器名、方法名
收发邮件(Mailing) | Yii 2.0 权威指南
Yii2中各种文本框的使用 [ 2.0 版本 ]
Yii Model中rules验证 获取错误信息
Yii2之gii的配置与使用
yii2面包屑Breadcrumbs的使用
Yii2行为(Behavior)简介
使用行为(behavior)可以在不修改现有类的情况下,对类的功能进行扩充。 通过将行为绑定到一个类,...
揭秘yii2中行为的方法是如何注入到组件类中去的,应该说行为
推荐内容
怎样使用V2Ray代理和SSTap玩如魔兽世界/绝地求生/LOL台...
在网上找的ss+SSTap的方式都不能通过SSTap的链接测试。最后找到了v2ray+SSTap的方式。
注意事项,首先单独有v2ray看能不能正常上网。另外加速时要v2ray和SST...
使用V2Ray的mKCP协议加速游戏
当前脚本已发布新版本,地址:
https://github.com/kuoruan/shell-scripts/raw/master/kcptun/kcptun.sh
旧仓库已废...
v2rayN已停止工作
要安装.NET Framework 4.6 或者更高版本
超省心游戏加速:Wireguard+udp加速(CentOS版)--(
Wireguard+udpspeeder+udp2raw游戏加速方案
---------------------------------------错误报告及解决-----------...
wireguard+udpspeeder+udp2raw多用户配置
Wireguard+udpspeeder+udp2raw游戏加速方案改进版-实测有效
Wireguard+udpspeeder+udp2raw游戏加速方案改进版-实测有效
关于客户端电脑的虚拟网卡配置IP和DNS自动获取