Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Set default value for each uploaded image on image gallery

Go to End



Community Member, 1 Post

30 April 2013 at 1:50am

Edited: 30/04/2013 1:56am


I have an image gallery and I would like to set for each uploaded image a default path value, which should be similar to the breadcrumbs. My code it's here, so my question is what should I write to 'Path' => '', so that in my database would be saved the breadcrumbs ?
For example if my gallery is located on this url: 'http://localhost/prosteel/projektgalerie/projekt-2/', than I would like to set the default value 'Projektgalerie Projekt 2'. I hope you can help me.

class ImageResource extends DataObject
static $db = array (
'Path' => 'Text',
'Caption' => 'Text'

static $has_one = array (
'Attachment' => 'Image', //Needs to be an image
'Projects' => 'Projects'

static $defaults = array(
'Path' => ''

public function getCMSFields_forPopup()
return new FieldSet(
new TextareaField('Caption'),
new FileIFrameField('Attachment')