Adding configuration entries when creating a FCKeditor instance

When you create a instance of FCKeditor using any of the integration methods (javascript, PHP, asp, coldfusion...) you first create an object, but that object isn't the real FCKeditor object (it might be obvious when talking about server integration methods, as FCKeditor is run as javascript in the client, not on the server. But but difference is very important when creating the object in javascript).

You can check the properties of that object in the fckeditor.* files at the root of the distribution, but basically they are:

Instance name

The name of the FCKeditor object. It will be used when the data is sent back to the server as another form element, or you can use the FCKeditorAPI.GetInstance function from the API to get the FCKeditor object and work with it from Javascript.

Width, Height

Obviously the Width and Height that will be used to create the element in the page.


The toolbar that you want to use for this instance.


The folder where the FCKeditor files are in your server. If you put a wrong value here you'll get lots of errors and nothing will work.


That's all. There are no more properties on the creation of the FCKeditor instance.

And you might ask "How am I supposed to configure any additional option?, Am I forced to always modify the fckconfig.js file?"

Well, I've lied a little, there's one extra property, the Config object, that's an object that allows to set pairs of propertie:value for the configuration options that you might set in the fckconfig.js file. There are some very important restrictions: you can't set here any OBJECT or ARRAY, you can set only STRINGS, NUMBERS or BOOLEAN values. But besides that restrictions, you are free to add any value here, as long as you set something that it's correct then you don't have to modify the fckconfig.js (I mean something valid, because some people write just anything here and expect it to magically work. It must be something that is allowed as a property of FCKConfig. in the fckconfig.js file

Let's do some examples with the GoogleMaps_Key value used in the GoogleMaps plugin:

In Javascript:

var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
oFCKeditor.Config["GoogleMaps_Key"] = 'ABQIAAAAlXu5Pw6DFAUgqM2wQn01gxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSy5hTGQdsosYD3dz6faZHVrO-02A';


$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->Config['GoogleMaps_Key']  = 'ABQIAAAAlXu5Pw6DFAUgqM2wQn01gxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSy5hTGQdsosYD3dz6faZHVrO-02A' ;

In Asp:

Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.Config("GoogleMaps_Key") = "ABQIAAAAlXu5Pw6DFAUgqM2wQn01gxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSy5hTGQdsosYD3dz6faZHVrO-02A"

It's just the same for every language, you use the "creator" object, and then set in its Config object the property that you want.


1 comment:

Jota said...

In ASP, you can use this way:
oFCKeditor.Config['GoogleMaps_Key'] = "JFJOAJDPFAIJSPIDJFPADJFPA"