2017 © Pedro Peláez
 

yii2-extension yii2-sitemap

Yii2 sitemap component

image

pendalf89/yii2-sitemap

Yii2 sitemap component

  • Sunday, March 4, 2018
  • by PendalF89
  • Repository
  • 1 Watchers
  • 1 Stars
  • 94 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Yii2 sitemap

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

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

or add, (*3)

"pendalf89/yii2-sitemap": "*"

to the require section of your composer.json file., (*4)

Apply migration, (*5)

yii migrate --migrationPath=vendor/pendalf89/yii2-sitemap/src/migrations

Configuration:, (*6)

'components' => [
    'sitemap' => [
        'class' => 'pendalf89\sitemap\Sitemap',
        'sitemaps'  => [
                'frontend\sitemaps\ArticlesSitemap', // see example of class below
                'frontend\sitemaps\OtherSitemap', // see example of class below
            ],
        'generator' => [
            'class'   => 'pendalf89\sitemap\SitemapGenerator',
            'path'    => '@frontend/web',
            'baseUrl' => 'https://example.com',
        ],
    ],
],

Usage

In first, create sitemap classes, for example:, (*7)

namespace frontend\sitemaps;

use pendalf89\sitemap\SitemapInterface;

class OtherSitemap implements SitemapInterface
{
    /**
     * @inheritdoc
     */
    public function getName()
    {
        return 'sitemap-other';
    }

    /**
     * @inheritdoc
     */
    public function getUrls()
    {
        return [
            ['loc' => '/any-url/'],
            ['loc' => '/any-url-width-date/', 'lastmod' => '2016-09-02 12:23:17'],
        ];
    }
}

So, when you create sitemap classes, you can use component for create sitemap files., (*8)

Yii::$app->sitemap->update();

Also, you can update one url in DB:, (*9)

Yii::$app->sitemap->updateUrl('/any-url-width-date/', '2016-09-02 12:23:17');

The Versions

04/03 2018

dev-master

9999999-dev

Yii2 sitemap component

  Sources   Download

MIT

The Requires

 

by Zabolotskikh Boris