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.

Customising the CMS /

Modify FileField


Reply


19 Posts   3269 Views

Avatar
JuLo

Community Member, 37 Posts

9 December 2009 at 12:31am

@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

Avatar
Fuzz10

Community Member, 787 Posts

9 December 2009 at 12:31am

Edited: 09/12/2009 12:31am

@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 ....

Avatar
JuLo

Community Member, 37 Posts

9 December 2009 at 12:36am

Yep. I am using a has_one

Avatar
Fuzz10

Community Member, 787 Posts

9 December 2009 at 12:38am

;-)

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

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

Avatar
JuLo

Community Member, 37 Posts

9 December 2009 at 12:44am

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.

Avatar
Fuzz10

Community Member, 787 Posts

9 December 2009 at 12:47am

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

Please post your code...

Avatar
JuLo

Community Member, 37 Posts

9 December 2009 at 12:55am

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.

Avatar
Fuzz10

Community Member, 787 Posts

9 December 2009 at 1:17am

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