Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » HtmlEditorField editor field not displaying content in page

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

Page: 1
Go to End
Author Topic: 1210 Views
  • Roweena
    Avatar
    Community Member
    28 Posts

    HtmlEditorField editor field not displaying content in page Link to this post

    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!

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: HtmlEditorField editor field not displaying content in page Link to this post

    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',
       );

  • Roweena
    Avatar
    Community Member
    28 Posts

    Re: HtmlEditorField editor field not displaying content in page Link to this post

    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)

    1210 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.