Development

isicsSitemapXMLPlugin

You must first sign up to be able to contribute.

isicsSitemapXMLPlugin plugin

The isicsSitemapXMLPlugin provide 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:

 $ symfony plugin-install http://plugins.symfony-project.com/isicsSitemapXMLPlugin
 $ symfony cc
  • Modify the .htaccess file to redirect sitemap.xml to front controller:

 # we skip all files with .something
 # comment the following 3 lines to allow periods in routes
 RewriteCond %{REQUEST_URI} \..+$
 RewriteCond %{REQUEST_URI} !\.html$
 RewriteCond %{REQUEST_URI} !sitemap\.xml$
 RewriteRule .* - [L]

  • Enable the module isicsSitemapXML in settings.yml:

 all:
   .settings:
     enabled_modules:        [default, isicsSitemapXML]

Usage

Extending a module (nothing to do if the module is already "isicsSitemapXMLPlugin compatible")

Each module who has to add urls to sitemap.xml must implements the sitemapGenerator interface. The interface contains a generate() method to implement in a file named MODULENAME/lib/MODULENAMESitemapGenerator.class.php.

For instance, we take a news module. In news module lib dir, we create the file newsSitemapGenerator.class.php:

<?php

class newsSitemapGenerator implements sitemapGenerator
{
  
  public static function generate()
  {
    $urls = array();  
  
    $c = new Criteria();
    $c->addDescendingOrderByColumn(NewsArticlePeer::PUBLISH_UP);
    
    $articles = NewsArticlePeer::doSelect($c);
    
    foreach ($articles 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.

Configuration

Enable the modules in app.yml:

all:
  isicsSitemapXML:
    modules:       [ news ]

Just enjoy!!

Roadmap

  • Manage multiple Sitemaps and a Sitemap index (for sites with more than 50 000 URLs)

Changelog

2008-06-16 | 0.9.0-beta

  • Initial public release.

Attachments