Specifying the Editor Path"

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.

(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…')
 
(Article contents proof-read and formatted)
 
Line 1: Line 1:
As defined at the [[CKEditor_3.x/Developers_Guide/Integration|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:
+
As described in the [[CKEditor_3.x/Developers_Guide/Integration|Integration]] article, to make CKEditor work it is enough to include the <code>ckeditor.js</code> file in your pages. However, there are some situations when the original editor file name may not be used:
 
 
 
* The file must be renamed, for any reason.
 
* 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.
+
* 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 is different from <code>ckeditor.js</code>. This is the most common case.
* You have yet another file named "ckeditor.js", which is not in the editor installation directory.
+
* You have yet another file named <code>ckeditor.js</code> which is not placed in the editor installation directory.
  
 
== The Problem ==
 
== The Problem ==
 +
In order to work correctly  CKEditor needs to know where in the website it is installed. Thanks to that information the editor is able to load other resource files like skins, language files, plugins, etc. In other words, the editor installation path is needed.
  
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 is looking for the <code>ckeditor.js</code> file in the <code><script></code> tags present in the page in order to automatically retrieve its installation path. If it is not able to find it, just like in the cases presented above, the editor will simply not work.
 
 
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 ==
 
== The Solution: CKEDITOR_BASEPATH ==
 +
When loading the editor script, CKEditor is looking for the global <code>CKEDITOR_BASEPATH</code> JavaScript variable that contains the editor installation path. If it is defined, its value is used. Otherwise the automatic detection process described above takes place. In order to solve this uncommon loading issue it is thus enough to define the <code>CKEDITOR_BASEPATH</code> variable. For example:
  
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:
+
<source lang="javascript">
 
 
<pre>
 
 
<script type="text/javascript">
 
<script type="text/javascript">
 
var CKEDITOR_BASEPATH = '/ckeditor/';
 
var CKEDITOR_BASEPATH = '/ckeditor/';
 
</script>
 
</script>
 +
 
<script src="all_my_scripts.js" type="text/javascript"></script>
 
<script src="all_my_scripts.js" type="text/javascript"></script>
</pre>
+
</source>
  
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).
+
Note that this global JavaScript variable must be set '''''before''''' you include the CKEditor code. In the example above the variable definition was placed in-page, but it could also be included inside the <code>all_my_scripts.js</code> file, at the start of it (or in any case &mdash; before the editor code).

Latest revision as of 20:17, 29 August 2011

As described in the Integration article, to make CKEditor work it is enough to include the ckeditor.js file in your pages. However, there are some situations 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 is different from ckeditor.js. This is the most common case.
  • You have yet another file named ckeditor.js which is not placed in the editor installation directory.

The Problem

In order to work correctly CKEditor needs to know where in the website it is installed. Thanks to that information the editor is able to load other resource files like skins, language files, plugins, etc. In other words, the editor installation path is needed.

By default, CKEditor is looking for the ckeditor.js file in the <script> tags present in the page in order to automatically retrieve its installation path. If it is not able to find it, just like in the cases presented above, the editor will simply not work.

The Solution: CKEDITOR_BASEPATH

When loading the editor script, CKEditor is looking for the global CKEDITOR_BASEPATH JavaScript variable that contains the editor installation path. If it is defined, its value is used. Otherwise the automatic detection process described above takes place. In order to solve this uncommon loading issue it is thus enough to define the CKEDITOR_BASEPATH variable. 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 example above the variable definition was placed in-page, but it could also be included inside the all_my_scripts.js file, at the start of it (or in any case — before the editor code).

This page was last edited on 29 August 2011, at 20:17.