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   1177 Views

Avatar
Mgc

Community Member, 23 Posts

30 July 2009 at 5:01am

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

Forum Moderator, 4096 Posts

31 July 2009 at 1:14am

code?

Avatar
Mgc

Community Member, 23 Posts

31 July 2009 at 12:40pm

Edited: 31/07/2009 12:49pm

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

Forum Moderator, 4096 Posts

31 July 2009 at 2:19pm

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