Adding New Resource Types

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

(Article content moved to a template)
 
Line 1: Line 1:
To create a new resource type you should append the following lines of code anywhere after the "ResourceType type;" line in the configuration file.
+
{{Ckfinder_2.x_New_Resource_Types_Description|file=configuration|link=CKFinder_2.x/Developers Guide/ASP/Configuration/Resource Types/Built-in}}
  
For example, if want to create a resource type named MSdocs which will only accept files with the "doc", "ppt" and "xls" extensions, restricting the file size to 2 megabytes:
+
<source lang="asp">
<pre>type = ResourceType.Add( "MSdocs" );
+
type = ResourceType.Add( "MSdocs" );
 
type.Url = BaseUrl + "docs/";
 
type.Url = BaseUrl + "docs/";
type.Dir = BaseDir == ""&nbsp;? ""&nbsp;: BaseDir + "docs/";
+
type.Dir = BaseDir == "" ? "" : BaseDir + "docs/";
 
type.MaxSize = 2097152; // 2MB in Bytes
 
type.MaxSize = 2097152; // 2MB in Bytes
 
type.AllowedExtensions = new string[] { "doc", "ppt", "xls" };
 
type.AllowedExtensions = new string[] { "doc", "ppt", "xls" };
type.DeniedExtensions = new string[] { };</pre>  
+
type.DeniedExtensions = new string[] { };
The above options are described in the [[CKFinder_2.x/Developers Guide/ASP.NET/Configuration/Resource Types/Built-in|Built-in resource types]] section.
+
</source>  
  
By default, CKFinder will use all the resources types including the new one you have just created. If you want to limit the CKFinder to use only your resource type you must place its name in the in the '''DefaultResourceTypes''' setting. For example:
+
This code should be placed in the configuration file, anywhere after the <code>ResourceType type;</code> line.
<pre>DefaultResourceTypes = "MSdocs";
+
 
</pre>
+
{{Ckfinder_2.x_New_Resource_Types_Default|DefaultResourceTypes=DefaultResourceTypes}}
 +
 
 +
<source lang="asp">DefaultResourceTypes = "MSdocs";</source>

Latest revision as of 08:30, 31 March 2011

When you want to create a new resource type, you should place the section below in your configuration file. Note that the options you can use are described in the Handling Built-in Resource Types section.

Example: Suppose you want to create a new resource type named MSdocs, which will only be used for files with the .doc, .ppt, and .xls extensions and the maximum size of 2 megabytes. Add the following code to your configuration file.

type = ResourceType.Add( "MSdocs" );
type.Url = BaseUrl + "docs/";
type.Dir = BaseDir == "" ? "" : BaseDir + "docs/";
type.MaxSize = 2097152; // 2MB in Bytes
type.AllowedExtensions = new string[] { "doc", "ppt", "xls" };
type.DeniedExtensions = new string[] { };

This code should be placed in the configuration file, anywhere after the ResourceType type; line.

When loading CKFinder, the type querystring parameter can be used to display a specific type only. If type is omitted in the URL, the DefaultResourceTypes setting is used (it may contain the resource type names separated by a comma).

If the DefaultResourceTypes setting is left empty, all types — including the newly defined ones — are loaded. When you want to limit CKFinder to only use the newly defined MSdocs resource type, use the following code:

DefaultResourceTypes = "MSdocs";
This page was last edited on 31 March 2011, at 08:30.