1 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 Copyright (c
) 2003-2011, CKSource
- Frederico Knabben
. All rights reserved
.
4 For licensing
, see LICENSE
.html
or http
://ckeditor.com/license
6 <html xmlns
="http://www.w3.org/1999/xhtml">
8 <title
>Setting Configuration Options
&mdash
; CKEditor Sample
</title
>
9 <meta content
="text/html; charset=utf-8" http
-equiv
="content-type"/>
10 <link href
="../sample.css" rel
="stylesheet" type
="text/css"/>
14 CKEditor Sample
&mdash
; Setting Configuration Options
17 This sample shows how to insert a CKEditor instance with custom configuration options
.
20 To set configuration options
, use the
<a
class="samples" href
="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html"><code
>config
</code
></a
> property
. To set the attributes of a
<code
><
;textarea
>
;</code
> element (which is displayed instead of CKEditor in unsupported browsers
), use the
<code
>textareaAttributes
</code
> property
.
24 // Include the CKEditor class.
25 include_once "ckeditor/ckeditor.php";
27 // Create a class instance.
28 $CKEditor = new CKEditor();
30 // Path to the CKEditor directory.
31 $CKEditor->basePath
= '/ckeditor/';
33 // Set global configuration (used by every instance of CKEditor).
34 $CKEditor-><strong
>config
['width']</strong
> = 600;
36 // Change default textarea attributes.
37 $CKEditor-><strong
>textareaAttributes
</strong
> = array("cols" => 80, "rows" => 10);
39 // The initial value to be displayed in the editor.
40 $initialValue = 'This is some sample text.';
42 // Create the first instance.
43 $CKEditor->editor("textarea_id", $initialValue);
46 Note that
<code
><em
>textarea_id
</em
></code
> in the code above is the
<code
>name
</code
> attribute of
47 the
<code
><
;textarea
>
;</code
> element to be created
.
50 <!-- This
<div
> holds alert messages to be display in the sample page
. -->
54 <strong
>CKEditor requires JavaScript to run
</strong
>. In a browser with no JavaScript
55 support
, like yours
, you should still see the
contents (HTML data
) and you should
56 be able to edit it normally
, without a rich editor
interface.
60 <form action
="../sample_posteddata.php" method
="post">
61 <label
>Editor
1:</label
>
63 // Include the CKEditor class.
64 include("../../ckeditor.php");
66 // Create a class instance.
67 $CKEditor = new CKEditor();
69 // Do not print the code directly to the browser, return it instead.
70 $CKEditor->returnOutput
= true;
72 // Path to the CKEditor directory, ideally use an absolute path instead of a relative dir.
73 // $CKEditor->basePath = '/ckeditor/'
74 // If not set, CKEditor will try to detect the correct path.
75 $CKEditor->basePath
= '../../';
77 // Set global configuration (will be used by all instances of CKEditor).
78 $CKEditor->config
['width'] = 600;
80 // Change default textarea attributes.
81 $CKEditor->textareaAttributes
= array("cols" => 80, "rows" => 10);
83 // The initial value to be displayed in the editor.
84 $initialValue = '<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>';
86 // Create the first instance.
87 $code = $CKEditor->editor("editor1", $initialValue);
92 <label
>Editor
2:</label
>
94 // Configuration that will only be used by the second editor.
95 $config['toolbar'] = array(
96 array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
97 array( 'Image', 'Link', 'Unlink', 'Anchor' )
100 $config['skin'] = 'v2';
102 // Create the second instance.
103 echo $CKEditor->editor("editor2", $initialValue, $config);
106 <input type
="submit" value
="Submit"/>
112 CKEditor
- The text editor
for the Internet
- <a
class="samples" href
="http://ckeditor.com/">http
://ckeditor.com</a>
115 Copyright
©
; 2003-2011, <a
class="samples" href
="http://cksource.com/">CKSource
</a
> - Frederico
116 Knabben
. All rights reserved
.