3215 Posts in 848 Topics by 811 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 883 Views |
-
MetaTags are missing after changing URL interpretation by Director::addRules

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:
Director::addRules(100, array(
'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.
-
Re: MetaTags are missing after changing URL interpretation by Director::addRules

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?
-
Re: MetaTags are missing after changing URL interpretation by Director::addRules

20 September 2010 at 2:57am
Yes it does, it´s a child of Page.
-
Re: MetaTags are missing after changing URL interpretation by Director::addRules

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
function MetaTags($includeTitle){
return SiteTree::MetaTags($includeTitle);
}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.
-
Re: MetaTags are missing after changing URL interpretation by Director::addRules

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.
| 883 Views | ||
|
Page:
1
|
Go to Top |


