If you have created a custom data object that you want to make SEO friendly (for examnple Products in a commerce system) then you can by following these steps:
In order for this module works correctly, your object will need the following DB fields:
- Title
- Content
- URLSegment
- MetaDescription
The SEO module needs to access the SiteConfig associated with the current object, so you need to ensure you add the following to your object class (this is taken directly from SiteTree.
class YourSEODataObject extends DataObject
{
...
/**
* Stub method to get the site config, unless the current class can provide an alternate.
*
* @return SiteConfig
*/
public function getSiteConfig() {
if($this->hasMethod('alternateSiteConfig')) {
$altConfig = $this->alternateSiteConfig();
if($altConfig) return $altConfig;
}
return SiteConfig::current_site_config();
}
...
}
We now need to extend your current object to utilise the SeoSiteTreeExtension, you can do this in two ways:
class YourSEODataObject extends DataObject
{
...
private static $extensions = array(
"SeoSiteTreeExtension"
);
...
}
YourSEODataObject:
extensions:
- SeoSiteTreeExtension
Finally run a dev/build?flush=1 and then ensure you flush the admin interface (with ?flush=1).