Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Set default value for each uploaded image on image gallery

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

Page: 1
Go to End
Author Topic: 380 Views
  • eri90
    Avatar
    Community Member
    1 Post

    Set default value for each uploaded image on image gallery Link to this post

    Hello!

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

    380 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.