Reputation: 1914
When using a DataObject as page, the MetaTags(false|true)
loses its functionality. How can you make it work?
Controller action for retrieving DataObject
public function article(SS_HTTPRequest $request) {
$article = NewsArticle::get()->find("URL", $request->param('ID'));
if(!$article) {
return $this->httpError(404);
}
return array (
'Article' => $article,
'Title' => $article->Title,
'MetaDescription' => $article->MetaDescription
);
}
Upvotes: 2
Views: 157
Reputation: 1199
The MetaTags function is located in SilverStripes sitetree class.
Just copy it to your newsarticle dataobject and adjust it to fit your needs.
If you want to display more dataobjects than that one as a page, you should think about packing all the basic stuff like urlsegment, metatags, link ... in one class and than just extend this one.
There's also a module with does that DataObject-as-Page
Upvotes: 1