Line 26: | Line 26: | ||
=== Configuration options === | === Configuration options === | ||
− | As explained in [[CKFinder_2.x/Developers_Guide/PHP/Configuration#JavaScript_Configuration|JavaScript Configuration]] section, it is possible to configure CKFinder using '''config.js'''. Because the create() method accepts configuration object as the first argument, we can also pass configuration options inline instead of modyfing config.js (thus making it possible to configure each instance of CKFinder | + | As explained in [[CKFinder_2.x/Developers_Guide/PHP/Configuration#JavaScript_Configuration|JavaScript Configuration]] section, it is possible to configure CKFinder using '''config.js'''. Because the create() method accepts configuration object as the first argument, we can also pass configuration options inline instead of modyfing config.js (thus making it possible to configure each instance of CKFinder separately): |
<source> | <source> |
Revision as of 13:52, 17 May 2010
Contents
JavaScript integration
The JavaScript integration method is the most powerful. There are several ways to integrate CKFinder into your pages. This page presents the most common way to achieve it.
Step 1: Loading CKFinder
CKFinder is a JavaScript application. To load it, you just need to include a single file reference at your page. Supposing that you have [[CKFinder_2.x/Developers_Guide/{{{language}}}/Installation|installed]] CKFinder at the "ckfinder" directory at the root of your web site, here you have an example:
<head> ... <script type="text/javascript" src="/ckfinder/ckfinder.js"></script> </head>
With the above file loaded, the CKFinder JavaScript API is ready to be used.
Step 2: Creating an Application Instance
Next thing to do, to have the CKFinder up & running, is creating an application instance:
<script type="text/javascript"> var finder = new CKFinder(); finder.basePath = '/ckfinder/'; finder.create(); </script>
(put this code anywhere inside of the <body>
tag). For an example please check the standalone sample distributed with CKFinder (_samples/js/standalone.html).
Configuration options
As explained in JavaScript Configuration section, it is possible to configure CKFinder using config.js. Because the create() method accepts configuration object as the first argument, we can also pass configuration options inline instead of modyfing config.js (thus making it possible to configure each instance of CKFinder separately):
<script type="text/javascript"> var finder = new CKFinder(); finder.basePath = '/ckfinder/'; // Setting custom width and user language. finder.create({ width : 700, language : 'de' }); </script>
CKFinder is smart enough to recognize configuration options assigned directly to the CKFinder instance, the following code does exactly the same as the code above:
<script type="text/javascript"> var finder = new CKFinder(); finder.basePath = '/ckfinder/'; // Setting custom width and user language. finder.width = 700; finder.language = 'de'; finder.create(); </script>
Available methods
create()
Renders CKFinder in the current document.
function create( config )
accepts one argument:
-
config
- (Optional) The specific configurations to apply to this application instance. Configurations set here will override global CKFinder settings.
popup()
The popup() method opens CKFinder in a popup.
function popup( config )
accepts one argument:
-
config
- (Optional) The specific configurations to apply to this application instance. Configurations set here will override global CKFinder settings.