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

Displaying Content from the DOM on a template


Reply

4 Posts   1128 Views

Avatar
Mgc

30 July 2009 at 5:01am Community Member, 23 Posts

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.

Avatar
UncleCheese

31 July 2009 at 1:14am 4085 Posts

code?

Avatar
Mgc

31 July 2009 at 12:40pm (Last edited: 31 July 2009 12:49pm), Community Member, 23 Posts

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;
   }

}
?>

Avatar
UncleCheese

31 July 2009 at 2:19pm 4085 Posts

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