3443 Posts in 1030 Topics by 871 members
|Go to End|
20 September 2010 at 1:27am
One of my page types doesn´t show the meta data (keywords, description) in the frontend after I customized the URL interprtation:
'view/$ID/$Name' => 'SomePage_Controller'
Is this a bug? What can I do about it? As soon as I remove this rule, the meta keywords etc will show in the xhtml code.
20 September 2010 at 2:56am
MetaTags are part of SiteTree. So if you don't have a SiteTree (or subclass), the method is not available.
Does SomePage_Controller return a Page somewhere?
20 September 2010 at 2:57am
Yes it does, it´s a child of Page.
20 September 2010 at 10:40am Last edited: 20 September 2010 10:50am
Presumably, you are returning a DataObject through that page.
add the following to your DataObject class
Because you are accessing the controller directly, there is no Page object associated with the request and therefore no existing Meta Tags to use. The above code will allow you to return the Meta Tag values you have assigned to your DataObject through your view function.
20 September 2010 at 7:23pm
I am showing a DataObject on that page by urlParams['ID']. I tried SiteTree::MetaTags() as a return value but it didn´t work. MetaTags in not a static function.
Thanks for Your hint anyways. I implemented a function MetaTags() in the SomePage_Controller and now it works. This isn´t a clean solution i suppose.
|Go to Top|