Maintainer(s):
camspiers
Supported by: Not supported
Visit the support forum Download
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.
http://code.google.com/p/simple-sitemap/source/browse/trunk/README
http://code.google.com/p/simple-sitemap/issues/list
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;
}
}
}
?>
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.
Version:
[v0.2]
Date: 2010-07-01
Compatible with: SilverStripe 2.2, 2.3, 2.4
Download:
simple-sitemap-v0.2.tar.gz
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/
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.