November Happy Hour will be moved to Thursday December 5th.

List of Images

Vote:
 

How can I declare my property in my class that I want to have a list of images? As of now I can only think about using LinkItemCollection, but that dosen't seem to be a good way. I only want to be able to select images. This property is going to be used for a image slider.

#77786
Nov 26, 2013 11:40
Vote:
 

Using the LinkItemCollection is one option. Another option is to have a URL to folder property. Then you can have all the images that you would like displayed in the slider within the folder that the property points to. There is no built in URL to folder property but it is pretty easy to add one. If you want to try that option I can post some code snippets.

#77813
Nov 26, 2013 15:12
Vote:
 

Yes please post a example on how that works with the folder.

 

The reason why I don't like LinkItemCollection to go with is because I only want the editor to select images and not be able to add a document or just a link so it will fail the javascript slider outcome. If you find out a solution for this before I do, please contribute with it. :)

#77830
Nov 27, 2013 2:25
Vote:
 

Hey Daniel,

Unfortunetly Ha Bui has a habit of posting code for versions of EPiServer that haven't been released yet ;) so his example wont work in your case.

The solution that I suggested with the URL to Folder property makes use of the existing file picker from the legacy UI but we tell it that we only want to be able to select folders. Otherwise it functions like any other URL property. So on your model you would have a property like this:

[UIHint("Folder")]
public virtual Url FolderUrl { get; set; }

The UIHint is important here as it tells the UI what editor to use. This mapping is done via an EditorDescriptor object. In this case we create one to map a property of type Url with a UIHint of Folder to the FileSelector:

[EditorDescriptorRegistration(TargetType = typeof(Url), UIHint = "Folder")]
public class FolderUrlEditorDescriptor : EditorDescriptor
{
    public FolderUrlEditorDescriptor()
    {
        ClientEditingClass = "epi-cms.widget.FileSelector";
        EditorConfiguration["fileBrowserMode"] = "folder";
    }
}

Hopefully that is all you need to get the property working. After that, in your controller, you can load up the value of the property as a UnifiedDirectory and get the files contianed within.

Let me know if you have any problems.

#77838
Nov 27, 2013 9:25
Vote:
 
#77840
Edited, Nov 27, 2013 10:11
Vote:
 

@Ben

This doesn't seem to work with EPiServer 7.5 - perhabs the client editing class is changed?

#79747
Jan 03, 2014 10:06
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.