Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

HtmlEditorField editor field not displaying content in page


Go to End


3 Posts   2189 Views

Avatar
Roweena

Community Member, 28 Posts

29 January 2009 at 9:17am

I've seen a few other posts with this problem, but no real solution and I'm really beginning to pull my hair out. I've added a second HtmlEditorField editor field to the CMS for entering testimonials, but the content that is added in the cms doesn't display in the web page.

My .php page is as follows:

class CoursesPage extends Page {
static $db = array(
);
static $has_one = array(
'Photo' => 'Image',
'Testimonials' => 'HTMLText'
);

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

$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Testimonials', 'Add Testimonials'));
return $fields;
}
}

class CoursesPage_Controller extends Page_Controller {

}

My .ss is as follows:

<div id="Testimonials" style="float: right; width: 180px; border: 1px solid #ccc">
$Testimonials
</div>

I've flushed and rebuilt but to no avail. The Image tab show above does however work ok.

PLEASE HELP!

Avatar
Hamish

Community Member, 712 Posts

29 January 2009 at 10:24am

HTMLText is a database field, not a relation, so change this:

class CoursesPage extends Page {
	static $db = array(
	);
	static $has_one = array(
		'Photo' => 'Image',
		'Testimonials' => 'HTMLText'
	);

to...

class CoursesPage extends Page {
	static $db = array(
		'Testimonials' => 'HTMLText'
	);
	static $has_one = array(
		'Photo' => 'Image',
	);

Avatar
Roweena

Community Member, 28 Posts

29 January 2009 at 10:59pm

THANK YOU! That works now, still trying to get my head round how this all works.

(BTW for anyone who might be looking at this and still getting to grips with php there shouldn't be a comma after 'Photo' => 'Image' as shown below, this will throw an error)