(Created page with 'As defined at the Integration page, it's enough to include the "ckeditor.js" file into your pages to have CKEditor working. There ar…') |
(No difference)
|
Revision as of 09:37, 12 October 2009
As defined at the Integration page, it's enough to include the "ckeditor.js" file into your pages to have CKEditor working. There are some situations though when the original editor file name may not be used:
- The file must be renamed, for any reason.
- The original editor script is merged with other scripts used in the page, to reduce the number of files being downloaded. This single file will also have a name that's not "ckeditor.js". This is the most common case.
- You have yet another file named "ckeditor.js", which is not in the editor installation directory.
The Problem
For the editor to work, it needs to understand where in the web site it's installed. In this way it's able to load other resource files, like skins, language files, plugins, etc. In other words, the editor installation path is needed.
By default, CKEditor looks for the "ckeditor.js" file in the <script> tags present in the page to automatically retrieve its installation path. If it's not able to find it, just like in the cases presented above, it will simply not work.
The Solution: CKEDITOR_BASEPATH
When loading the editor script, CKEditor looks for the global "CKEDITOR_BASEPATH" JavaScript variable, containing the editor installation path. If it's defined, it's value is used, otherwise the above automatic detection takes place. So, to solve this uncommon loading issue it's enough to define it. For example:
<script type="text/javascript"> var CKEDITOR_BASEPATH = '/ckeditor/'; </script> <script src="all_my_scripts.js" type="text/javascript"></script>
Note that this global JavaScript variable must be set before you include the CKEditor code. In the above example we've placed the variable definition in-page, but it could also be included inside the "all_my_scripts.js" file, at the start of it (at least before the editor code).