enchikiben/yii2-sitemap

Yii2 generation Sitemap XML

Installs: 9 120

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 1

Forks: 1

Open Issues: 1

Type:yii2-extension

0.0.2 2019-06-03 16:54 UTC

This package is auto-updated.

Last update: 2024-10-29 04:09:28 UTC


README

Installation

The preferred way to install this extension is through composer.

php composer.phar require --prefer-dist "enchikiben/yii2-sitemap" "*"

or

"enchikiben/yii2-sitemap" : "*"

Configure

'modules' => [
    'sitemap' => [
        'class' => 'enchikiben\sitemap\Sitemap',
        'controllerDirAlias' => '@frontend/controllers'
    ],
],

Add a new rule for urlManager of your application's configuration file, for example:

'urlManager' => [
    'rules' => [
        ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],
    ],
],

Use

class SiteController extends Base
{

    /**
     * @sitemap priority=1
     */
    public function actionIndex()
    {
    } 

    /**
     * @sitemap priority=0.8
     */
    public function actionConfidentiality()
    {
    }
}

or

class NewsController extends Base
{
    /**
     * @sitemap priority=0.5 changefreq=monthly route=['/news/view','id'=>$model->id] model=common\models\News condition=['status'=>1]
     */
    public function actionView($id)
    {
        
    }
}