alpiiscky/yii2-sitemap

Генерация Sitemap по крону

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

0.1 2018-03-07 06:31 UTC

This package is not auto-updated.

Last update: 2024-05-17 00:46:22 UTC


README

Генерация Sitemap по крону

Установка

Выполнить

composer require --prefer-dist alpiiscky/yii2-sitemap "*"

или добавить

"alpiiscky/yii2-sitemap": "*"

в composer.json.

Настройка

Добавить в раздел components файла console.php:

'sitemap' => [
    'class' => 'alpiiscky\sitemap\components\SitemapComponent',
    'filename' => 'sitemap.xml',
    'basePath' => '@webroot',
    'siteUrl' => 'http://<домен>'
],

Создать в папке commands контроллер. Массив $items заполняется по циклам

<?php

namespace app\commands;

use yii\console\Controller;
use Yii;

class SitemapController extends Controller
{
    public function actionIndex()
    {
        $sitemap = Yii::$app->sitemap;

        $items = [
            ['loc' => 'ef', 'changefreq' => 'weekly', 'priority' => 0.5],
        ];

        $sitemap->add($items);
        $sitemap->render();
    }
}