Faloude Faloude - 5 months ago 41
PHP Question

SilverStripe retrieving MetaTags(param) on a DataObject as page

When using a DataObject as page, the

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


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