We've moved! You can find modules, themes and widgets on http://addons.silverstripe.org.
This page will no longer be updated, and disappear soon. Module maintainers, please read our announcement to find out how to add your modules there.

Simple Sitemap [v0.2]

Maintainer(s): camspiers
Supported by: Not supported

Module that allows you to produce a sitemap which contains entries from DataObject and SiteTree records.

Gives more flexibility then the current googlesitemaps module, but needs configuration in your php code.

 

Readme/Docs

http://code.google.com/p/simple-sitemap/source/browse/trunk/README

Issue Tracker

http://code.google.com/p/simple-sitemap/issues/list

Guide

To install drop the simple-sitemap folder into your silverstripe root.

To have records appear in the sitemap you need to implement the SitemapResourceInterface interface.

Here are a couple of examples, one of a DataObject and one SiteTree:

Example: Category.php
-----------------------------------------------

<?php

class Category extends DataObject implements SitemapResourceInterface {

	static $db = array(
		'Name' => 'Varchar(255)',
		'SitemapShow' => 'Boolean'
	);

	public function SitemapUrlPriority(){
		return 0.8;
	}

	public function SitemapUrlLoc(){
		return Director::absoluteURL($this->Link());
	}

	public function SitemapUrlChangeFreq(){
		return SimpleSitemap::DAILY;
	}

	public function SitemapUrlLastMod(){
		return $this->dbObject('LastEdited')->Format('c');
	}

	public function SitemapUrlShow(){
		return $this->SitemapShow;
	}
	
	public function Link(){
		return '/category/' . $this->ID;
	}

}

?>


Example: Page.php
-----------------------------------------------

<?php

class Page extends SiteTree implements SitemapResourceInterface{

	public function SitemapUrlPriority() {
			switch ($this->ClassName) {
					case 'HomePage':
							return 1;
							break;
					default:
							return 0.8;
							break;
			}
	}

	public function SitemapUrlLoc() {
			return Director::absoluteURL($this->Link());
	}

	public function SitemapUrlChangeFreq() {
			switch ($this->ClassName) {
					case 'HomePage':
							return SimpleSitemap::DAILY;
							break;
					default:
							return SimpleSitemap::WEEKLY;
							break;
			}
	}

	public function SitemapUrlLastMod() {
			return $this->dbObject('LastEdited')->Format('c');
	}

	public function SitemapUrlShow() {
			switch ($this->ClassName) {
					case 'ErrorPage':
							return false;
							break;
					default:
							return true;
							break;
			}
	}
	
}

?>

 

Caching

To cache the sitemap it is best to set up a cron to to run the a sake task:

sake sitemap.xml/cache

Make sure that you you have your _ss_environment.php file set up with $_FILE_TO_URL_MAPPING set up like so: 

global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/Users/cameron/Sites/sitemaptest'] = 'http://sitemaptest';

Otherwise the absolute urls will not work correctly.

 

Module screenshot

Release(s)

  • Latest release

    Version: [v0.2]
    Date: 2010-07-01
    Compatible with: SilverStripe 2.2, 2.3, 2.4
    Download: simple-sitemap-v0.2.tar.gz

  • Older release(s)

    Version: [v0.1]
    Date: 2010-01-11
    Compatible with: SilverStripe
    Download: svn-trunk-r5.tar.gz

    Subversion access: http://simple-sitemap.googlecode.com/svn/trunk/

  • Latest trunk build

    To get a preview of our next release, download the latest build of unstable trunk here. Please be careful: this is more likely to contain bugs, especially on modules undergoing a lot of development.

    Revision: #5
    Build Date: 2010-07-01
    Download: svn-trunk-r5.tar.gz

    Unstable Subversion access: http://simple-sitemap.googlecode.com/svn/trunk/

 
 

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.