Best way to create property to pick folder

Vote:
 

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!

#77625
Nov 21, 2013 18:15
Vote:
 

Regarding nr 2, yes I have used it with EPiServer 7 (though the UI seriously needs an upgrade).

Frederik

#77626
Nov 21, 2013 18:29
Vote:
 

The out-of-the-box functionality is to have a string property, and then let the editor drag-n-drop folders into that property.

#77749
Nov 25, 2013 20:32
Vote:
 

HaBu, that works for block folders. Not file folders. It will probably work in 7.5 as well with the new filemanagement.

#77757
Nov 26, 2013 6:01
Vote:
 

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; }

    

#77759
Edited, Nov 26, 2013 6:29
Vote:
 

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

See: http://world.episerver.com/Documentation/Javascript-Library/?documentId=cms/7/epi/cms/widget/UrlSelector

 

Hope that help!

HaBu

#77760
Nov 26, 2013 7:36
Vote:
 

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";

    

#77763
Edited, Nov 26, 2013 8:29
Vote:
 

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-libraryhttp://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

#77764
Nov 26, 2013 8:43
Vote:
 

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.

#77839
Edited, Nov 27, 2013 9:43
Vote:
 

Thanks, will try it out!

#77843
Nov 27, 2013 10:51
Vote:
 

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

#77905
Nov 28, 2013 10:43
Vote:
 

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.

#77910
Nov 28, 2013 11:12
Vote:
 

Many thanks to Ben for that information and sorry Andreas!

Keep silent is best for me in this case! :D

So sorry again!

/HaBu

#77915
Nov 28, 2013 11:23
Vote:
 

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

#77947
Nov 29, 2013 4:08
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.