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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Specific content in Pages


Reply


5 Posts   324 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, 4094 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!