A CakePHP Plugin for adding automatic XML and HTML Sitemaps to an CakePHP app
- Only generates a sitemap currently for models in the core App, not in Plugins.
- Generates an HTML list using a dl list.
- Generates an sitemap.xml file as well.
- View caching used for the HTML files.
- Allows for setting a custom callback function to build urls.
- PHP 5.3+
- CakePHP 2.1+
$ composer require loadsys/cakephp_sitemap:~1.0
- Add this this line to your
bootstrap.php
:
CakePlugin::load(array('Sitemap' => array('routes' => true, 'bootstrap' => true)));
- Add the behavior to the model desired to generate a sitemap for that model
public $actsAs = array(
'Sitemap.Sitemap' => array(
'primaryKey' => 'id', // Default primary key field
'loc' => 'buildUrl', // Default function called that builds a url, passes parameters (Model $Model, $primaryKey)
'lastmod' => 'modified', // Default last modified field, can be set to FALSE if no field for this
'changefreq' => 'daily', // Default change frequency applied to all model items of this type, can be set to FALSE to pass no value
'priority' => '0.9', // Default priority applied to all model items of this type, can be set to FALSE to pass no value
'conditions' => array(), // Conditions to limit or control the returned results for the sitemap
)
);
- Sitemap should now be visible at /sitemap and /sitemap.xml
Please use GitHub Isuses for listing any known defects or issues.