Hi,
I have been using the sample here.. http://silverstripe.org/dataobjectmanager-module-forum/show/274900#post274900..
Basically this is to show products and I have replaced the standard ImageField with a manager
// replaced this
new ImageField('ProductImage')
// with a ImageDataObjectManager like
new ImageDataObjectManager(
$this,
'Galleries',
'Gallery',
'Attachment',
array('Description' => 'Description')
)
);
This is all great... I am wanting to take it a bit further though and show the first image from the gallery in the backend... kindof like showing a thumbnail from the ProductImage. ie: http://www.ssbits.com/adding-a-thumbnail-to-a-dataobjectmanager-or-complex-table-field/
Any Ideas.. I tried but it was asking me for a "fortemplate" function.. I added this to the gallery dataobject but dont know how to access data inside that.. any ideas.. my gallery object is included below..
<?php
class Gallery extends DataObject
{
static $db = array (
'Name' => 'Text',
'Description' => 'Text' );
static $has_one = array (
'Attachment' => 'Image',
'Product' => 'Product'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextareaField('Description'),
new FileIFrameField('Attachment')
);
}
function forTemplate() {
// how to access gallery objects here..
// namely get first image from gallery items.
}
}