Hi, i am looking to use the folder pick to allow a client to select a subfolder within the website structure. i have followed you brief install instructions and am able to get the folder picker to show in a content page after adding it to the datatypes and a document type. What i am trying to work out is how i can use the folder path to pass to a macro that could be part of that content page and template, that will list all of the contents of that folder (subfile, ie images, documents, subfolders etc). could you suggest any way to use this path now i can select it. and if you know how to write a macro that will list contents of a folder would be helpfull too. the content of the folder have not ben added to umbraco, they will be FTP'd up to the folder. Thanksyou for you help.
sorry for the long long delay, I forgot you completely...
You get as output the virtual path of the selected folder. e.g. if you have selected the folder images under your root folder you get as output "/images". Therefore that it is stored as the value of the generic property in the node you can use this in an xslt via
To list all files under a certain node you have to do some .net coding because there is no build in method to list all files of a folder, but this can easy be done with an xslt extension like this (not tested):
public static XPathNodeIterator GetFilesFromFolder(string virtualFolder) { var server = System.Web.HttpContext.Current.Server; var folder = server.MapPath(virtualFolder); var doc = new XDocument(); var root = new XElement("Files"); doc.Add(root); XPathNavigator nav = doc.CreateNavigator();
if (string.IsNullOrEmpty(folder)) return nav.Select("/Files");
foreach (var filePath in Directory.GetFiles(folder)) { var entry = new XElement("File"); root.Add(entry);
entry.Add(new XElement("FileName", new XText(Path.GetFileName(filePath)))); entry.Add(new XElement("Extension", new XText(Path.GetExtension(filePath)))); entry.Add(new XElement("FilePath", new XText(filePath))); entry.Add(new XElement("VirtualFilePath", new XText(server.MapPath(filePath)))); }
return nav.Select("/Files"); }
So you can use this (after installing this extension) via
I have already followed your installation:
Installation: Just upload the dll to the bin folder, add a new datatype in the developer/datatypes section and choose TH.FolderPicker as RenderControl. Now you can select the base path from which the datatype will pick the folders. In the content section then the tree will be shown from the base path.
But I can't see TH.Folder Picker in developer/datatypes. How do?
Use of folder location from folder picker
Hi, i am looking to use the folder pick to allow a client to select a subfolder within the website structure. i have followed you brief install instructions and am able to get the folder picker to show in a content page after adding it to the datatypes and a document type. What i am trying to work out is how i can use the folder path to pass to a macro that could be part of that content page and template, that will list all of the contents of that folder (subfile, ie images, documents, subfolders etc). could you suggest any way to use this path now i can select it. and if you know how to write a macro that will list contents of a folder would be helpfull too. the content of the folder have not ben added to umbraco, they will be FTP'd up to the folder. Thanksyou for you help.
Hi Owen,
missed your post completely. Have a lot of meetings today, but will answer this evening.
Thomas
Hi Owen,
sorry for the long long delay, I forgot you completely...
You get as output the virtual path of the selected folder. e.g. if you have selected the folder images under your root folder you get as output "/images". Therefore that it is stored as the value of the generic property in the node you can use this in an xslt via
To list all files under a certain node you have to do some .net coding because there is no build in method to list all files of a folder, but this can easy be done with an xslt extension like this (not tested):
So you can use this (after installing this extension) via
hth, Thomas
HI Thomas Hohler,
I have already followed your installation: Installation: Just upload the dll to the bin folder, add a new datatype in the developer/datatypes section and choose TH.FolderPicker as RenderControl. Now you can select the base path from which the datatype will pick the folders. In the content section then the tree will be shown from the base path.
But I can't see TH.Folder Picker in developer/datatypes. How do?
thanks and best regards akl
is working on a reply...