I'm currently working on an image slider for the home page of the site I'm working on, and I've had no problems setting up the many_many
relationship and UploadField
in the CMS. My problem is that I want to have a clickthrough link for each image in the carousel.
How should I represent this in my model, and is there any quick and painless solution that I can use to seamlessly allow the user to associate a URL with the image they just uploaded.
Here's my code thus far:
class HomePage extends Page {
private static $many_many = array(
'Images' => 'Image'
);
public function getCMSFields ()
{
$fields = parent::getCMSFields();
$upload = new UploadField('Images', 'Slider Images (JPG or PNG)', $this->Images()); // Create a new upload field and set its name to 'Logo'.
$upload->setAllowedExtensions( array( 'JPG', 'PNG' ) );
$upload->setConfig('allowedMaxFileNumber', 5); // Allow 5 files for this field
return $fields;
}
}