Hi, at the moment I am displaying teasers from the PortfolioPage.php on the Homepage.php. Each portfolio page has a group of 3 images uploaded using the DataObjectManager.
At the moment I am displaying the Portfolio name, blurb and all 3 images on the homepage OK.
PROBLEM: I only want to display the first image of the group of 3 images on the homepage. Your assistance is appreciated.
Page.php
class Page_Controller extends ContentController {
...
public function RandomChildren($max = 1) {
return DataObject::get("PortfolioPage", null, "RAND()", null, "0, $max");
}
...
}
Homepage.ss
...
<% control RandomChildren(2) %>
<% control PortfolioImages %>
$MyPortfolioImage.SetWidth(180)
<% end_control %>
<% end_control %>
...
PortfolioImage.php
class PortfolioImage extends DataObject {
static $db = array (
'PortfolioImageTitle' => 'Text'
);
static $has_one = array (
'MyPortfolioImage' => 'Image',
'BelongToEventPage' => 'PortfolioPage'
);
public function getCMSFields_forPopup() {
return new FieldSet(
new TextField('PortfolioImageTitle'),
new FileIFrameField('MyPortfolioImage')
);
}
}