MCFileManager:TinyMCE Options/filemanager insert template

From Moxiecode Documentation Wiki

Jump to: navigation, search

Option: filemanager_insert_template

This option enables you to specify a template to use for inserting files into TinyMCE. The template should contain a HTML code snippet to insert and you can use variables like {$url} for example to get information out from the files that is being inserted. This template is only useful if you have the insertfile button added to TinyMCE.

Here are all the available variables

name
This is the file name of the file, for example myfile.gif.
path
This is the absolute path to the file such as /mydir/myfile.gif.
url
This is the absolute URL to the file such as http://www.somesite.com/mydir/myfile.gif remember TinyMCE will convert this URL into a relative URL by default. Consult the TinyMCE manuals for details.
size
File size of the file in bytes. For example 34567.
created
Creation date/time of the file based on the configured format.
modified
Modification date/time of the file based on the configured format.
attribs
List of file attributes currently only R or W for example: RW is read + write.
custom.<your custom name>
Some custom variable passed from a plugin.

You can also add your own custom variables. Check the CustomInfoExample plugin for details on how to do that.

Example of usage with TinyMCE

tinyMCE.init({
	...
	filemanager_insert_template : '<a href="{$url}" title="{$custom.mycustomfield}">{$name}</a>'
});
Custom insert function example
tinyMCE.init({
	...
	filemanager_insert_template : function(fo, enc) {
		return '<a href="' + enc.xmlEncode(fo.url) + '">Image: ' + enc.xmlEncode(fo.name) + ', Size: ' + enc.xmlEncode(fo.size) + '</a>';
	},
});
Personal tools