123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace sitemap;
- function print_a( $a ){
- echo "<pre>";
- print_r( $a );
- echo "</pre>";
- }
- use yii\base\BootstrapInterface;
- use yii;
- use yii\base\Module;
- class Sitemap extends Module implements BootstrapInterface
- {
- public $layout = "@sitemap/views/main.php";
- // public $defaultRoute = 'default';
- public function init()
- {
- parent::init();
- // $this->bootstrap();
- }
- /**
- * {@inheritdoc}
- */
- public function bootstrap($app)
- {
- // parent::bootstrap($app);
- $prefix = '/';
- if ($urlManager = $app->getUrlManager() && 0) {
- $urlManager->addRules([
- // $prefix . '<module:' . $this->id . '>/<controller:\w+>/<action:\w+>/<page:\d+>' => '<module>/<controller>/<action>',
- $prefix . '<module:' . $this->id . '>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
- $prefix . '<module:' . $this->id . '>/<controller:\w+>' => '<module>/<controller>/index',
- ], true);
- }
- $app->getUrlManager()->addRules([
- [
- 'pattern' => 'sitemap/sitemap',
- 'route' => '/sitemap/default/index',
- 'suffix' => '.xml'
- ],
- 'sitemap/sitemap.xml' => 'sitemap/default/index',
- 'sitemap/news/<page:\d+>' => 'sitemap/default/news'
- ], true);
- }
- }
|