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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Specific content in Pages


Go to End


5 Posts   748 Views

Avatar
vike888

Community Member, 2 Posts

6 December 2011 at 11:00pm

Edited: 07/12/2011 12:20am

Hi, I'd like to insert some boxes in homepage with a image and text. So in Page.php I set:
<?php
class Page extends SiteTree {

static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
'TeaserText' => 'Content',
'Picture' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Box', new HtmlEditorField("TeaserText","Text"));

$fields->addFieldToTab('Root.Content.Box', new ImageField('Picture'));

$fields->addFieldToTab('Root.Content.Main', new textField('Author'));
$fields->addFieldToTab('Root.Content.Main', new textField('Date'));

return $fields;
}
}

In Admin I see "Text" as editor and " Picture" as image. If I insert a new image and refresh the page in frontend the image appears but when I insert text or other in the editor I can't save anything.
I'd like to insert in admin text with editor to see in the pages text and image in specific boxes but SS doesn't allow me to save what I write in the editor.
How can I do?

thanks

Avatar
Juanitou

Community Member, 323 Posts

7 December 2011 at 1:44am

Hi!

You have an error here:

'TeaserText' => 'Content',

Reference: http://doc.silverstripe.org/sapphire/en/topics/data-types

Avatar
vike888

Community Member, 2 Posts

7 December 2011 at 3:01am

Hi Juanitou,
thanks for your reply.
I tried to understand where is the problem you highlighted but I really found it.
I tried to set
'TeaserText' => 'HTMLText',

but it dosen't work.
problably I'm PHP beginner

Could you explain me where is the issue?
thanks

Avatar
UncleCheese

Forum Moderator, 4102 Posts

7 December 2011 at 4:25am

It doesn't belong in your has_one array. It should be in $db.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Juanitou

Community Member, 323 Posts

7 December 2011 at 5:49am

Indeed!