Display ElementalArea in DataObject template

I have a setup fairly similar to Uncle Cheese’s example in the Lesson videos for displaying a DataObject in a Template.
I am using Elemental content blocks in my DataObject, but I can’t get $ElementalArea to display in my Template. If I use $ElementalAreaID in the template to test it, it displays the content block ID in the correct place, and all the other variables display properly.

What am I missing?

Maybe the element was not published? hard to tell without see codes

Thanks, but it was definitely published. I have admitted defeat on this one and changed the DataObject to a Page type, and everything works.
Would still be interested to hear if anyone else has had this issue though

I have Elemental working in my DataObjects.

I followed the steps here: Element in ModelAdmin DataObjects results 'I can't handle sub-URLs on class SilverStripe\Admin\LeftAndMainFormRequestHandler.' · Issue #718 · dnadesign/silverstripe-elemental · GitHub

The Model uses:

use DNADesign\Elemental\Extensions\ElementalPageExtension;
use DNADesign\Elemental\Forms\ElementalAreaField;

private static $extensions = [

public function getCMSFields()
	$fields = parent::getCMSFields();


	$fields->addFieldToTab('Root.Content elements', ElementalAreaField::create('ElementalArea', $this->ElementalArea(), $this->getElementalTypes()));


	return $fields;

I pass the DataObject to the template from a controller:

public function ViewPost(HTTPRequest $request)

	# Find the post
	$Post = NewsPost::get()
		->filter(['Permalink' => $permalink])

	$data = ['Post' => $Post];

	return $this->customise($data)->renderWith('Layout/NewsViewPage');

In the template:


I had the same problem. ElementalArea was there but did not render the elements. I traced it back to the fact that ElementalArea tests canView on each element which tests CanView on the DataObject. So this solves it:

public function CanView($member=null) {
    return true;
1 Like

Nice hack :wink: Code looks nice, too. Thanks!