Regarding nr 2, yes I have used it with EPiServer 7 (though the UI seriously needs an upgrade).
Frederik
The out-of-the-box functionality is to have a string property, and then let the editor drag-n-drop folders into that property.
HaBu, that works for block folders. Not file folders. It will probably work in 7.5 as well with the new filemanagement.
No, that won't work either. File folders are not IContent. In EPiServer 7.1.2 and below, they are UnifiedDirectory.
But with some minor modifications to your code, and with a custom ISelectionFactory, it should work. This is untested code though:
[EditorDescriptorRegistration(
TargetType = typeof(string),
UIHint = UIHint)]
public class FolderEditorDescriptor : EditorDescriptor
{
public const string UIHint = "FolderPicker";
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
this.SelectionFactoryType = typeof(FolderSelectionFactory);
this.ClientEditingClass = "epi-cms/contentediting/editors/SelectionEditor";
base.ModifyMetadata(metadata, attributes);
}
}
public class FolderSelectionFactory : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var root = HostingEnvironment.VirtualPathProvider.GetDirectory("GlobalFiles") as UnifiedDirectory;
return this.GetSelections(root, 0);
}
private IEnumerable<ISelectItem> GetSelections(UnifiedDirectory root, int level)
{
var folders = new List<ISelectItem>();
foreach (var folder in root.GetDirectories())
{
var text = new StringBuilder()
.Append((char)160, level)
.Append(" - ")
.Append(folder.Name)
.ToString();
folders.Add(new SelectItem()
{
Text = text,
Value = folder.VirtualPath
});
level = level + 2;
folders.AddRange(this.GetSelections(folder, level));
level = level - 2;
}
return folders;
}
}
And in your content type:
[UIHint(FolderEditorDescriptor.UIHint)]
[Display(
Name = "Folder",
GroupName = SystemTabNames.Content,
Order = 1)]
public virtual string Folder { get; set; }
Hi Johan,
I'm totally wrong!
But I think in this case we can use Url property instead of string and SelectionEditor!
Our editor can be UrlSelector (with custom selection mode param "browserselectionmode" is FileManagerSelectionMode.Folder).
Hope that help!
HaBu
Thanks for your answers! Will definitely try them out. How can you have so much inside knowledge of code specific 7.5? Has it been released yet? (I know everyyhing will get content but this is a bit more :P )
Another question as well, where do you find all of theese properties? Have been searching a lot.
this.ClientEditingClass = "epi-cms/contentediting/editors/SelectionEditor";
Hi Andreas,
I've some answers for your questions:
(1) Has it been released yet? No, not yet
(2) where do you find all of theese properties? You can use :
+ Document for EPiServer CMS 7: http://world.episerver.com/Documentation/CMS/?id=66787&epslanguage=en&version=7
+ Class-library: http://world.episerver.com/Documentation/Class-library/?documentId=cms/7/d4648875-d41a-783b-d5f4-638df39ee413
+ Javascript-Library: http://world.episerver.com/Documentation/Javascript-Library/?version=7&product=cms
or post any question here ;)
(3) (not important question) How can you have so much inside knowledge of code specific 7.5?
I think these aren't "so much" (just for me - although I'm a developer (facepalm)).
About Johan I think "ECD" in his picture profile said all ;)
BR
HaBu
Hey all, there is a solution to have a Url to Folder property in this thread: http://world.episerver.com/Forum/Developer-forum/EPiServer-7-CMS/Thread-Container/2013/11/List-of-Images/
It is similiar to what Ha Bui suggested with setting the browserselectionmode parameter of the file selector.
Hi,
Just want addition a bit from Ben's posting:
"If you add a reference to "EPiServer.Cms.Shell.UI" dll and make "FolderUrlEditorDescriptor" inherited from "EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.UrlEditorDescriptor" then everything done!"
[EditorDescriptorRegistration(TargetType = typeof(Url), UIHint = "FolderPicker")]
public class FolderUrlEditorDescriptor : UrlEditorDescriptor
{
public FolderUrlEditorDescriptor()
{
ClientEditingClass = "epi-cms.widget.FileSelector";
EditorConfiguration["fileBrowserMode"] = "folder";
}
}
Hope that help!
/HaBu
Please do not reference the EPiServer.Cms.Shell.UI.dll from your project. This assembly is located in the UI module (not the bin folder) and will cause you deployment and upgrade headaches if you reference it.
Olala
I should keep slient but I can not :)
Hey Andreas, please try this:
[ContentType(DisplayName = "FolderPickerBlock", GUID = "47f4bd03-03d2-44be-9316-0985067469b6", Description = "")]
public class FolderPickerBlock : BlockData
{
[Display(Name = "Folder link")]
[ClientEditor(
ClientEditingClass = "epi-cms.widget.FileSelector",
EditorConfiguration = "{ \"fileBrowserMode\": \"folder\" }"
)]
public virtual Url FolderUrl { get; set; }
}
Cheers!
Ha Bui
1. Is there a property to use when I want to pick a folder in admin?
If not
2. Has anyone tried this folder browsing property with EPiServer 7? https://www.coderesort.com/p/epicode/wiki/FolderBrowserProperty
3. If I need to create one myself, how do I do? I have done a dropdown myself but that's it, don't see how to create a whole document picker property.
Thanks!