Extend Select Path Form Control to include Media Library

SOS Childrensvillages asked on March 16, 2017 17:03

Hi, I've cloned the Select Path form control and have made the following additions/changes:

mConfig.HideLibraries = false;
mConfig.LibSelectedSite = (String.IsNullOrEmpty(selectedSiteName)) ? SiteContext.CurrentSiteName : selectedSiteName;
mConfig.LibGlobalLibraries = AvailableLibrariesEnum.All;
mConfig.LibGroupLibraries = AvailableLibrariesEnum.All;
mConfig.LibGroups = AvailableGroupsEnum.All;
mConfig.LibSites = AvailableSitesEnum.All;

However, I can't get the media library tab to show. Is there something I'm missing?

I also tried setting at the end of the method:

mConfig.LibSites = mConfig.ContentSites;
mConfig.LibSelectedSite = mConfig.ContentSelectedSite;

Thanks in advance

Recent Answers


Rui Wang answered on March 20, 2017 15:15

Hi, what version are you using? I cannot find Select Path form control in v9 and v10. Also, path for pages in content tree (stored in database) is very different than path for media library (on file system). So by clone that control may not work.

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on March 20, 2017 16:13

Hi Rui, I am using 8.2. Thanks

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 20, 2017 16:51

What is the original code file name? I don't see Select Path, unless you are talking about "Single path selector with permissions (obsolete)" form control.

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on March 21, 2017 15:20

Hi Rui,

Apologies, the correct display name is "Single path selector".

The original control is in CMS\CMSModules\Content\FormControls\DocumentsSelectPath.ascx.cs. The code name is "selectsinglepath"

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 21, 2017 15:41

Okay, I found the file. One last questions. Where are you trying to use this path selector? In a web part property, form or page type?

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on March 21, 2017 16:12

I want to use it in a webpart as the media library selector only selects the top level.

Thanks for your help!

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 21, 2017 16:26

I got some idea from the MediaSelectionControl which also utilize the dialog.

mConfig = new DialogConfiguration();
mConfig.SelectableContent = SelectableContentEnum.OnlyMedia;
mConfig.OutputFormat = OutputFormatEnum.URL;
mConfig.HideWeb = true;
mConfig.ContentSelectedSite = SiteContext.CurrentSiteName;

With that, at least the media library shows up, but you are selecting a file from there. Not just a path (you may do some trimming to get the path as a workaround).

But if you look into our Media Library web part, you will see the way to set a path to a media library folder is actually to select the library, and manually entered the path. If we don't have the media path select option available out of box, I doubt modifying the DialogConfiguration will work.

0 votesVote for this answer Mark as a Correct answer

SOS Childrensvillages answered on March 21, 2017 16:53

Ya I thought of just using a media selection control and labeling it something like "please select any image from folder you wish to use" and trimming back the path like you said but was hoping for a path selector that could go into the media library.

Thanks for your help anyway

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.