andrewdanilov/yii2-sitemap

组件可为您模型的模型、控制器动作或随机页面生成sitemap.xml。

安装: 5

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

1.0.0 2019-04-16 12:37 UTC

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',
			],
		],
	],
];