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   3094 Views

Avatar
JuLo

Community Member, 37 Posts

3 December 2009 at 6:12am

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

Community Member, 901 Posts

3 December 2009 at 10:24am

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

Community Member, 37 Posts

3 December 2009 at 12:22pm

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

Community Member, 244 Posts

3 December 2009 at 5:14pm

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

Community Member, 37 Posts

4 December 2009 at 1:17pm

Oh OK. That seems simple enough.

I'll give that a shot.
Thanks

Avatar
JuLo

Community Member, 37 Posts

8 December 2009 at 8:24pm

Edited: 08/12/2009 9:07pm

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

Community Member, 787 Posts

8 December 2009 at 11:38pm

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

Community Member, 244 Posts

9 December 2009 at 12:21am

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