in your page type class add in following
static $has_many = array (
'GalleryImages' => 'GalleryImage'
);
function getCMSFields() {
$fields = parent::getCMSFields();
...
$manager = new ImageDataObjectManager(
$this, // Controller
'GalleryImages', // Source name
'GalleryImage', // Source class
'MyGalleryImage', // File name on DataObject
array(
'GalleryImageTitle' => 'GalleryImageTitle'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab('Root.Content.GalleryImage',$manager);
...
return $fields;
}
add the following dataobject in a separate file
class GalleryImage extends DataObject
{
static $db = array (
'GalleryImageTitle' => 'Text'
);
static $has_one = array (
'MyGalleryImage' => 'Image', //relation needed for this DataObject
'BelongToEventPage' => 'EventPage' //relation needed to point back to your pagetype, my pagetype is EventPage.
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('GalleryImageTitle'),
new FileIFrameField('MyGalleryImage')
);
}
}
You would also need the add in following two module 'DataObjectManager', 'SWFUpload', remember to do a /dev/build?flush=1 after you upload this two module onto your server.
then in your template do following
<% if GalleryImages %>
<% control GalleryImages %>
<img src="$MyGalleryImage.URL" width="90" />
<% end_control %>
<% end_if %>