alexs / yii2-sitemap
Sitemap for Yii2 Framework.
1.1.5-stable
2017-09-20 08:12 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: >=2.0.6
Requires (Dev)
- php: >=7.0.0
- alexs/yii2-phpunittestcase: *
- phpunit/phpunit: ^6.2
This package is auto-updated.
Last update: 2024-10-25 13:19:20 UTC
README
Sitemap extension for Yii2
Rules
You'll need to create your sitemap, for example:
<?php
namespace app\components;
use alexs\yii2sitemap\BaseSitemap;
use yii\helpers\Url;
class Sitemap extends BaseSitemap
{
public function getUrls() {
$domain = 'http://examplesite.com';
$static_urls = [
$domain,
$domain . '/article',
$domain . '/another-article',
];
$dynamic_urls = [];
$dynamic_urls[] = Url::to(['/url/to'], true);
return array_merge($static_urls, $dynamic_urls);
}
}
And controller:
<?php
namespace app\controllers;
use app\components\Sitemap;
use yii\web\controller;
class SitemapController extends Controller
{
public function actions() {
return [
'generate'=>[
'class'=>'alexs\yii2sitemap\GenerateAction',
'SitemapClass'=>new Sitemap,
],
];
}
}
You can follow the url