本手册由zengl开源网的站长提供 首页:www.zengl.com Configuration File  配置文件 The editor comes with a rich set of configurations that makes it possible to customize its appearance, fe...

本手册由zengl开源网的站长提供 首页:www.zengl.com

Configuration File  配置文件

The editor comes with a rich set of configurations that makes it possible to customize its appearance, features and behavior. The main configuration file is named "fckconfig.js". You can find this file in the root of the FCKeditor installation folder.
 FCKeditor编辑器提供了很丰富的配置选项,这些选项可以方便的自定义它的外观,功能和行为。主要的配置文件是 "fckconfig.js" 。在您的FCKeditor 安装的根目录下就可以找到该文件。
 
Available Configuration Options  可用的配置选项。

Check out the configuration options list  to have a complete overview of each setting.  您可以通过 configuration options list  该链接查看到完整的配置选项的列表。

Overriding the Default Configurations  覆盖默认的配置

You can either edit the main configuration file or just override the settings you want to change in a separate file. JavaScript syntax is used to configure FCKeditor.  您既可以通过编辑主配置文件来改变原始的配置,也可以在一个单独的文件里写入您自己的配置。一般习惯于使用 javascript 的语法来配置 FCKeditor。

To simplify updating FCKeditor on your sites, the best approach is to put all your configuration in a separate file, outside the editor's package directory structure. In this way, you just need to overwrite the editor's directory to update it to a newer version.  如果想更方便快捷的更新FCKeditor 。最好的方式就是 前面提到的,在编辑器解压的目录外 再新建个单独的文件,然后将自己所有的相关配置都写入该文件,这样一来,您只需在更新时 覆盖编辑器所在的目录即可。

Step 1  步骤1

Create a file called, for example, "myconfig.js" and save it in the root directory (or any directory) of your web site. You custom settings will be placed in this file. For example, let's suppose you want to force the editor to always have its interface in French. Simply writte this code into your new file: 例如,创建一个 "myconfig.js" 的文件,保存到网站的根目录或其他目录下。你的配置信息将写入该文件中。例如,假设你想让编辑器的界面使用法语。可以在该文件中写入 如下的代码:

FCKConfig.AutoDetectLanguage = false ; //关闭自动语言检测

FCKConfig.DefaultLanguage = "fr" ; //使用 fr 表示使用法语作为默认语言。 

Step 2  步骤2

Now we have to tell the editor that it has to load my custom configuration. There are two methodes to do it: 现在我们必须告诉编辑器我们自己的配置文件的位置,有两种方式:

Method 1  方法1

Find the following line in the main configuration file (fckconfig.js): 在主配置文件 fckconfig.js 文件中找到下面这一行:

FCKConfig.CustomConfigurationsPath = '' ;

and put in the path of your custom configuration file:  然后把你的配置文件的路径填上去:

FCKConfig.CustomConfigurationsPath = '/myconfig.js' ;

The above method is good, but, as you can imagine, you lose the facility not to touch the original files. In any case it is easier to remember that you just need to change one line, and all the other things settings changes remain separated.
上面的方法是不错,但是,你可能已经意识到了 ---- 这样做 必须要修改原始的文件,这样一来,你必须记住 当升级后,还必须再次修改该文件的这一行。虽然这并不难记,但如果你觉得不方便,可以试试下面提到的方法2 。

Method 2   方法2

There is an even better way to have the same results as described above, but without touching the fckconfig.js file. You can set the custom configurations path directly in the page that uses the editor. This is an example to achive this in JavaScript:  有个更好的方法可以解决上面提到的问题-----即不用修改fckconfig.js文件。你可以在使用 编辑器的 网页中,在创建编辑器实例时,使用以前说过的 Config数组来设置自定义的配置文件的路径,下面以javascript 为例来说明:

var oFCKeditor = new FCKeditor( "FCKeditor1" ) ;

oFCKeditor.Config["CustomConfigurationsPath"] = "/myconfig.js"  ;

oFCKeditor.Create() ;

The same method can be used with your preferred server side language. Take a look at the samples to find out how to manipulate the configurations by code.  你可以在 PHP之类的服务端脚本中使用类似的方法,可以查看对应脚本的例子来找出具体操作的方式。

Configurations Loading Precedence    配置加载的优先权

When overriding configurations, the following steps are taken:   当重设配置时,会按以下的顺序来加载:

1 . The configurations in the main configuration file (fckconfig.js) are loaded.  1 。首先会加载 fckconfig.js 这个主配置文件里的配置选项。

2  . The configurations are overridden by the settings in the custom configuration file (if provided).  2 。如果提供了自定义的配置文件的话,就会以自定义文件里的设置覆盖掉先前加载的配置。

3 .  The configurations are finally overridden by the settings done inline in the editor page, except for the "CustomConfigurationsPath", which is set right after step 1.  3 。最后,在使用编辑器的网页创建编辑器实例时,所进行的配置,如使用 Config数组进行的设置 会成为最终的配置。除了,"CustomConfigurationsPath" 这个配置选项,如果在第一步即 fckconfig.js文件里设置了话,后面就不会被覆盖了。因为如果在 第一步进行了设置,那么第二步自定义文件就会被加载,所以第三步也就没有设置这个选项的必要了。

You don't need to include all configuration options in your custom file, just those you want to change. Your file will "override" the default one.   在你的自定义的配置文件中,没必要包含所有的配置选项,只需包含你要改变的选项。你的文件中的这些选项在第二步将会覆盖默认的值。

NOTE

:You need to keep the original configuration file, "fckconfig.js", in the editor directory. Don't delete it or you will break FCKeditor.  注意:你必须保留编辑器所在目录的原始的配置文件 ---- "fckconfig.js",不可以删除它,否则你的FCKeditor将不能正常工作。

Browser Caching   浏览器缓存的处理

NOTE: remember to clear your browser cache when making changes to the configuration files, otherwise you may not see your changes. This is especially important when working behind a proxy which may cache your .js files more persistently than pages. There are a few tricks that can be used while developing to retrieve the latest version of the configuration file:
注意:当修改了配置文件后,要记得清空浏览器的缓存,否则你可能看不到配置文件改变后的效果,当使用代理的时候,会长时间的缓存你的 js 脚本文件,所以要记得清空缓存,下面有几个技巧可以快速的加载更改后的配置文件 同时又可以避免那些麻烦的清空浏览器缓存的操作:

If you are using Internet Explorer, hitting CTRL + F5 should suffice to update the latest versions of the script. No need to manually clear the browser cache. 如果你使用的是IE 浏览器,可以 按 ctrl + F5 就可以重新加载脚本文件了,不需要手工去清理浏览器的缓存。

If you are using Firefox or other Mozilla's children, hitting Shift+CTRL + R should update the latest version with no need to clear the cache (although this method doesn't seem to work at all times, if this fails clear cache manually).
如果你使用的是 火狐 或 其他的Mozilla 系列的子产品,可以 按 Shift+CTRL + R  就可以重新加载脚本了,如果这个方法失效,那时就只有手工清理缓存了。

You could add a number or code in the end of the custom configuration path, so the browser would be forced to load it every time:  第三种方法,你可以在自定义配置文件的路径后加一些数据或代码(一般是随机产生的数据比较好),这样浏览器每次都会强制重新加载脚本文件,这种方法在网站 更新验证码的图片时经常会用到!如下所示,使用了日期。

var oFCKeditor = new FCKeditor( "FCKeditor1" ) ;

oFCKeditor.Config["CustomConfigurationsPath"] = "/myconfig.js?" + ( new Date() * 1 ) ;

oFCKeditor.Create() ;

 OK,FCKeditor的配置部分先讲到这,休息,休息哈。

如果本文有翻译不周的地方,或有其他方面的评论,可以到下方发表评论。

上下篇

下一篇: FCKeditor的工具条设置

上一篇: PHP脚本加载fckeditor编辑器

相关文章

FCKeditor的调试

FCKeditor手册结束语

FCKeditor的JavaScriptAPI

JavaScript脚本加载fckeditor编辑器

FCKeditor的样式设置

FCKeditor自定义文件浏览器