How to set the starting node for the Document selector

   —   
By default, the Document selector form control displays all documents. However, you can use custom code to enable selection of the starting node.
To achieve that, you would need to go to the following file in which the document selector is defined:

~\CMSModules\Content\FormControls\Documents\SelectDocument.ascx.cs

You will need to specify a new property, let’s called it StartingPath:

public string StartingPath
{
 get
 {
    return ValidationHelper.GetString(GetValue("StartingPath"), String.Empty);
 }
 set
 {
    SetValue("StartingPath ", value);
    this.Config.ContentStartingPath = HttpUtility.UrlEncode(value);
 }
}


and add the following line to the Dialog property:

this.mConfig.ContentStartingPath = HttpUtility.UrlEncode(this.StartingPath);

Then, go to the Site manager -> Development -> Form controls -> Document selector -> Properties -> add a new property of type ‘string’ and with Column name set to StartingPath.

At this point, you should be able to define the starting path in the field settings that use the Document selector field,  for example Starting path = /Images.
 
-ml-


Applies to: Kentico CMS 6.x
Share this article on   LinkedIn