Jump to:

5522 Posts in 1734 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Modify FileField

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

Page: 1 2 3
Go to End
Author Topic: 3009 Views
  • JuLo
    Avatar
    Community Member
    37 Posts

    Re: Modify FileField Link to this post

    @Fuzzio, thanks anyway.

    @ajshort.
    Thanks a lot.
    That's what I was looking for.

    I have to say that it's not the first I struggle with that kind of stuff in the Silverstripe documentation.
    How did you know that the content of TreeDropdownField field can be displayed as URL or as Relative path?
    What are the other options?
    Where do you find that kind of info?

    I seem to only get it from reading posts on the forum of users who have already used it before (e.g. that's how I found out about $Locale.Nice)
    (Probably very weird question I know)

    JuLo

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Modify FileField Link to this post

    @AJShort : Well yeah , but we are not sure he is using a has_one ... Many times I've used a dropdown to store a link to the filesystem or the sitetree without having a relationship ....

  • JuLo
    Avatar
    Community Member
    37 Posts

    Re: Modify FileField Link to this post

    Yep. I am using a has_one

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Modify FileField Link to this post

    ;-)

    Haha , your previous posting beat me to it...

    Good to see it's sorted ! ... ;) Good luck with your project !

  • JuLo
    Avatar
    Community Member
    37 Posts

    Re: Modify FileField Link to this post

    Thanks Fuzzio.

    But that just showed me that I must have done something else wrong, because my TreeDropdownField does not seem to save its content.

    $FolderForBanner.URL always shows http://localhost/SilverStripe/assets/, no matter what folder I have chosen.

    And in the CMS, when I change it, Save And Publish, and refresh the page, the drop down is back to "(Choose)", which I guess means that it did not save the value.

    Any ideas.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Modify FileField Link to this post

    Just a quick guess : if you are using a has_one , you should probably safe to FolderForBannerID instead of FolderForBanner ...

    Please post your code...

  • JuLo
    Avatar
    Community Member
    37 Posts

    Re: Modify FileField Link to this post

    OK. I have no idea what that means (what ID? Where do I get it from?), so I am posting the code. (unnecessary bits removed)

    in Homepage.php
    (...)
    static $has_one = array(
    'FolderForBanner' => 'Folder'
       );

    public function getCMSFields(){

          $fields = parent::getCMSFields();
          (..)
          $fields->addFieldToTab("Root.Content.Banner", new TreeDropdownField("FolderForBanner", "Choose a folder to get the images for the slideshow from", "Folder"));
          (...)
             
          return $fields;
    }   

    In the Homepage.ss
    (...)
    $FolderForBanner.URL
    (...)

    And as I said earlier, it only returns "http://localhost/SilverStripe/assets/", which suggests that it does not save the value.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Modify FileField Link to this post

    Try :
    $fields->addFieldToTab("Root.Content.Banner", new TreeDropdownField("FolderForBannerID", "Choose a folder to get the images for the slideshow from", "Folder"));

    3009 Views
Page: 1 2 3
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.