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


Go to End
Reply

19 Posts   3080 Views

Avatar
JuLo

3 December 2009 at 6:12am Community Member, 37 Posts

Hi,

I'd like to modify FileField (or create a new type of field) so it can accept a folder instead of only files.

(I basically just want to have a browse button and save the path that I pointed to)

Can anyone point me into the right direction?

Thanks

Julien

Avatar
banal

3 December 2009 at 10:24am Community Member, 901 Posts

I don't quite understand what you're trying to do.
Do you want to select a folder on your local computer and store the path to that folder?
Or do you want to be able to select a folder on the server (from the assets folder)?

Avatar
JuLo

3 December 2009 at 12:22pm Community Member, 37 Posts

A folder on the server.

I've created a sort of slideshow in Flash and would like to be able to pass a path to it (through a php) to tell it which folder to get its pictures from.

Thanks in advance for your help.

Avatar
ajshort

3 December 2009 at 5:14pm Community Member, 244 Posts

You can just use TreeDropdownField with a DataObjectSet of all the folders. Something like "new TreeDropdownField('Folder', 'Select a Folder', 'Folder')" should do the job.

Avatar
JuLo

4 December 2009 at 1:17pm Community Member, 37 Posts

Oh OK. That seems simple enough.

I'll give that a shot.
Thanks

Avatar
JuLo

8 December 2009 at 8:24pm (Last edited: 8 December 2009 9:07pm), Community Member, 37 Posts

Ok.
I tried it by including this in my pages getCMSfields
      $fields->addFieldToTab("Root.Content.Banner", new TreeDropdownField("FolderForBanner", "Choose a folder to get the images for the slideshow from", "Folder"));

It seems to work.

But I don't know how to use the selected path in the .ss Page.
If I just put $FolderForBanner in the ss file, it obviously cannot work.
How to turn this "path object" into a string?

Some more help please?

Thanks.

Avatar
Fuzz10

8 December 2009 at 11:38pm Community Member, 787 Posts

First get the folder-object in your code .... And feed that to your template :

$tmpFolder = DataObject::get_by_id("Folder",$FolderForBannerID);
return $tmpFolder

Avatar
ajshort

9 December 2009 at 12:21am Community Member, 244 Posts

Actually that is completely unnecessary. You can just access a $has_one relationship in your template by using $HasOneName. You then can do $HasOneName.URL or $HasOneName.RelativePath or whatever in your template.

Go to Top