Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Displaying Content from the DOM on a template

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: 1067 Views
  • Mgc
    Avatar
    Community Member
    23 Posts

    Displaying Content from the DOM on a template Link to this post

    Hi all,

    I am working with the DOM and I have to say works pretty well. I have one issue though. How do I get the data from the CMS to display on the front end?

    I followed the sample code form the DOM tutorial page. But once the data is placed and I view the page on the front end it does not display the template or any of the data.

    I would appreciate the help thanks.

  • UncleCheese
    Avatar
    4085 Posts
  • Mgc
    Avatar
    Community Member
    23 Posts

    Re: Displaying Content from the DOM on a template Link to this post

    Here is my code. I am assuming that i have too make a template for the testimonials page, But since i am a noob I am not sure how.

    I guess my question is how do I get the data to appear on the page?

    Testimonial.php.....

    <?php

    class Testimonial extends DataObject
    {
       static $db = array (
          'Date' => 'Date',
          'Author' => 'Text',
          'Quote' => 'HTMLText'
       );
       
       static $has_one = array (
          'TestimonialPage' => 'TestimonialPage'
       );
          
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new CalendarDateField('Date'),
             new TextField('Author'),
             new TextareaField('Quote')
          );
       }
    }
    ?>

    TestimonialPage.php

    <?php
    class TestimonialPage extends Page
    {
       static $has_many = array (
          'Testimonials' => 'Testimonial'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $f->addFieldToTab("Root.Content.Testimonials", new DataObjectManager(
             $this,
             'Testimonials',
             'Testimonial',
             array('Date' => 'Date','Author'=>'Author','Quote' => 'Quote'),
             'getCMSFields_forPopup'
          ));
          return $f;
       }

    }
    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Displaying Content from the DOM on a template Link to this post

    I would encourage you to download the example code or read the tutorials on DOM to get a good introduction.

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