Hey,
Thanks. I've posted the relevant code below. The code is just displaying the data from a data object called Course things like Date, title, location etc... on the front page. What's odd is that it's not even getting called when in the layout file.
Page.php
------------
class Page_Controller extends ContentController {
...
public function DisplayCourse(){
die('function called'); //To test if function is getting called
$courses = DataObject::get("Course");
$results = ($courses) ? DataObject::get("Course", "", "", "", "") : false;
return ($results) ? $results : false;
}
}
Layout/Homepage.ss
----------------------------
...
<% control DisplayCourse %>
<div>
<p><strong>$Date.Nice</strong></p>
<p>$Location</p>
<p class="purple"><strong>$Title</strong></p>
<p class="purple">$Description</p>
› <a href="#" class="read-more">Read more</a>
</div>
<% end_control %>
....
Course.php
--------------
<?php
class Course extends DataObject
{
static $db = array (
'Date' => 'Date',
'Location' => 'Text',
'Title' => 'Text',
'Description' => 'Text'
);
static $has_one = array (
'LearningAndDevelopmentPage1' => 'LearningAndDevelopmentPage1',
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new CalendarDateField('Date', 'Date of the course'),
new TextField('Location', 'Location of the course'),
new TextField('Title', 'Title of the course'),
new TextareaField('Description', 'Description of the course')
);
}
}
?>