Hi,
I've customised the CMS so that the user can chosse multiple uploaded images to display in an image scroller using a treemultiselect field.
Done this as follows:
public static $many_many = array(
"ChooseImages" => "File"
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.PhotoGallery', new TreeMultiSelectField('ChooseImages', 'Select images for gallery:', 'File'), '');
return $fields;
}
this is then called in the template as:
<% control ChooseImages %><img src="$Link" border="0" height="110" width="167" ><% end_control %>
This works perfectly, and loads up every image that the user selected.
However if I only want to call the first item of the array (eg only access the first image that is selected) how do I do that? Assuming its a function, tried a few things but no success... eg in the page controller
class CoursePage_Controller extends Page_Controller {
function GetFirstPic() {
$a = ChooseImages[0];
return ($a);
}
}
Didn't really expect it to work, but worth a try! ;-)