# isicsSitemapXMLPlugin plugin The isicsSitemapXMLPlugin provides an easy way to generate a sitemap.xml. Each module (from plugins or not) who implements the sitemapGenerator interface adds automatically its owns urls. ## Features * Quick to use (nothing to do if the module already implements the interface) * Cached (24h of lifetime by default) ## License The isicsSitemapXMLPlugin is licensed under the GNU Lesser General Public License (LGPL). ## Installation * Install the plugin: [plain] $ symfony plugin:install isicsSitemapXMLPlugin $ symfony cc ## Usage Each module who has to add urls to sitemap.xml must listen to isicsSitemapXML.filter_urls event. For instance, we take a news module. In config.php, we declare the listener: [php] $this->dispatcher->connect('isicsSitemapXML.filter_urls', array('NewsTools', 'filterUrls')); We add the listener: [php] /** * Listens to the isicsSitemapXML.filter_urls event. * * @param sfEvent $event An sfEvent instance * @param array $urls An array of urls to filter * * @return array The filtered urls array */ public static function filterUrls(sfEvent $event, $urls) { foreach (NewsArticlePeer::getPublished() as $article) { $urls[] = new sitemapURL('@news_article?slug='.$article->getSlug(), $article->getPublishUp('c')); } return $urls; } ``Note the 'c' value of getPublishUp() param to get an ISO 8601 date.`` Enabled isicsSitemapXML module in your settings.yml: [plain] all: .settings: enabled_modules: [default, isicsSitemapXML] You can now see your sitemap.xml in /sitemap.xml. Just enjoy!! ### Add default urls You can add default urls by 2 ways: 1. Using configuration: [plain] all: isicsSitemapXML: modules: [ news ] default_urls: url1: loc: mymodule1/myaction1 url2: loc: mymodule1/myaction2 changefreq: never priority: 1 2. Redifining addDefaultUrls() method: [php] require_once(dirname(__FILE__).'/../../../plugins/isicsSitemapXMLPlugin/modules/isicsSitemapXML/lib/BaseisicsSitemapXMLActions.class.php'); class isicsSitemapXMLActions extends BaseisicsSitemapXMLActions { protected function addDefaultUrls() { $this->urls[] = new sitemapURL('mymodule1/myaction1'); $this->urls[] = new sitemapURL('mymodule1/myaction2', null, 'never', 1); } } ## Changelog ### 2009-05-19 | 2.0.2 * Fixed README * Updated package.xml ### 2009-05-08 | 2.0.0 * New version for Symfony 1.2 based on events ### 2008-09-11 | 0.9.1-beta * Update README to markdown (Gordon Franke) * Add cast for priority to float (Gordon Franke) * Avoid disabling short open tag (Gordon Franke) * Adding default urls support (idea from Gordon Franke) ### 2008-06-16 | 0.9.0-beta * Initial public release.