I have a TestimonalHolder
page type that has Testimonials
page type as its children which each have a Message
$db field to store a testimonal.
Question is how do I access that $Message
field on my HomePage.ss
for example so I can loop through them and will put them into a slider etc.
Testimonials.php
class Testimonials extends Page {
private static $db = array(
'Message' => 'Text'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldsToTab('Root.Testimonials', array(
TextareaField::create('Message')
));
return $fields;
}
}
class Testimonials_Controller extends Page_Controller {
}
I know I can loop through them by using this code on my TestimonialHolder.ss
page:
<% loop $Children %>
<h2>$Title</h2>
$Message
<% end_loop %>