Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Specific content in Pages

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 254 Views
  • vike888
    Avatar
    Community Member
    2 Posts

    Specific content in Pages Link to this post

    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

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Specific content in Pages Link to this post

    Hi!

    You have an error here:

    'TeaserText' => 'Content',

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

  • vike888
    Avatar
    Community Member
    2 Posts

    Re: Specific content in Pages Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Specific content in Pages Link to this post

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

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

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Specific content in Pages Link to this post

    Indeed!

    254 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.