Pigeon: Thanks, that was not exactly what I was looking for, but the site is great and has lots of other interesting stuff.
Martijn: Great Extension, but it's also not quite what I'm looking for. I want to overwrite the "MetaTags" function so I can call "$MetaTags(0)" in my template and get the output generated by my module.
For now I solved it by overwriting the function in the controller, but I think that's not very clean. The original function is located in SiteTree, which is the model.
_config.php
DataObject::add_extension('SiteTree', 'SiteTreeExtension');
DataObject::add_extension('Page_Controller', 'SiteTreeExtension_Controller');
SiteTreeExtension.php
class SiteTreeExtension extends DataObjectDecorator {
}
class SiteTreeExtension_Controller extends Extension {
public function MetaTags($includeTitle = true) {
// Vars
$version = SapphireInfo::Version();
$charset = ContentNegotiator::get_encoding();
$currentLang = i18n::convert_rfc1766(Translatable::get_current_locale());
$lastChangedDate = date("Y-m-d\TH:i:sP", strtotime($this->owner->LastEdited));
// Set Array
$metaData = array(
array("generator", "SilverStripe $version - http://www.silverstripe.com"),
array("Content-type" , "text/html; charset=$charset"),
array("keywords" , Convert::raw2att($this->owner->MetaKeywords)),
array("description" , Convert::raw2att($this->owner->MetaDescription)),
array("Content-Language" , $currentLang),
array("date" , $lastChangedDate)
);
$tags = "";
foreach($metaData as $metaLine) {
$tags .= $metaLine[1] != "" ? "<meta name=\"$metaLine[0]\" content=\"$metaLine[1]\" />\n" : "";
}
if ($this->ExtraMeta) {
$tags .= $this->ExtraMeta."\n";
}
$this->extend('updateMetaTags', $tags);
$this->extend('MetaTags', $tags);
return $tags;
}
}
(Obviously far from being finished)