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

Set default value for each uploaded image on image gallery




30 April 2013 at 1:50am (Last edited: 30 April 2013 1:56am), Community Member, 1 Post


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')