PHP code example of andrewdanilov / yii2-sitemap

1. Go to this page and download the library: Download andrewdanilov/yii2-sitemap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andrewdanilov / yii2-sitemap example snippets


return [
	...
	'components' => [
		...
		'sitemap' => [
			'class' => andrewdanilov\sitemap\Sitemap,
			'urls' => [
				// Full notation for ActiveRecord model.
				// All found records will be collected for building sitemap.
				[
					'class' => 'frontend\models\Products',
					'url' => ['catalog/product'],
					'attribute' => 'id', // optional
					'changeFreq' => andrewdanilov\sitemap\LocParams::WEEKLY, // optional
					'priority' => 0.1, // optional
					'lastMod' => 0, // optional
				],
				// Full notation for single url/action.
				[
					'url' => ['catalog/index'],
					'changeFreq' => andrewdanilov\sitemap\LocParams::WEEKLY, // optional
					'priority' => 0.1, // optional
					'lastMod' => 0, // optional
				],
				// Short notation for single url/action
				['catalog/index'],
				// Short notation for single random url
				'category1/product123?page=2',
			],
		],
	],
];