JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _samples / php / advanced.php
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2 <!--\r
3 Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
4 For licensing, see LICENSE.html or http://ckeditor.com/license\r
5 -->\r
6 <html xmlns="http://www.w3.org/1999/xhtml">\r
7 <head>\r
8         <title>Setting Configuration Options &mdash; CKEditor Sample</title>\r
9         <meta content="text/html; charset=utf-8" http-equiv="content-type"/>\r
10         <link href="../sample.css" rel="stylesheet" type="text/css"/>\r
11 </head>\r
12 <body>\r
13         <h1 class="samples">\r
14                 CKEditor Sample &mdash; Setting Configuration Options\r
15         </h1>\r
16         <p>\r
17                 This sample shows how to insert a CKEditor instance with custom configuration options.\r
18         </p>\r
19         <p>\r
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>&lt;textarea&gt;</code> element (which is displayed instead of CKEditor in unsupported browsers), use the <code>textareaAttributes</code> property.\r
21         </p>\r
22         <pre class="samples">\r
23 &lt;?php\r
24 // Include the CKEditor class.\r
25 include_once "ckeditor/ckeditor.php";\r
26 \r
27 // Create a class instance.\r
28 $CKEditor = new CKEditor();\r
29 \r
30 // Path to the CKEditor directory.\r
31 $CKEditor->basePath = '/ckeditor/';\r
32 \r
33 // Set global configuration (used by every instance of CKEditor).\r
34 $CKEditor-><strong>config['width']</strong> = 600;\r
35 \r
36 // Change default textarea attributes.\r
37 $CKEditor-><strong>textareaAttributes</strong> = array("cols" => 80, "rows" => 10);\r
38 \r
39 // The initial value to be displayed in the editor.\r
40 $initialValue = 'This is some sample text.';\r
41 \r
42 // Create the first instance.\r
43 $CKEditor->editor("textarea_id", $initialValue);\r
44 ?&gt;</pre>\r
45         <p>\r
46                 Note that <code><em>textarea_id</em></code> in the code above is the <code>name</code> attribute of\r
47                 the <code>&lt;textarea&gt;</code> element to be created.\r
48         </p>\r
49 \r
50         <!-- This <div> holds alert messages to be display in the sample page. -->\r
51         <div id="alerts">\r
52                 <noscript>\r
53                         <p>\r
54                                 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript\r
55                                 support, like yours, you should still see the contents (HTML data) and you should\r
56                                 be able to edit it normally, without a rich editor interface.\r
57                         </p>\r
58                 </noscript>\r
59         </div>\r
60         <form action="../sample_posteddata.php" method="post">\r
61                         <label>Editor 1:</label>\r
62 <?php\r
63 // Include the CKEditor class.\r
64 include("../../ckeditor.php");\r
65 \r
66 // Create a class instance.\r
67 $CKEditor = new CKEditor();\r
68 \r
69 // Do not print the code directly to the browser, return it instead.\r
70 $CKEditor->returnOutput = true;\r
71 \r
72 // Path to the CKEditor directory, ideally use an absolute path instead of a relative dir.\r
73 //   $CKEditor->basePath = '/ckeditor/'\r
74 // If not set, CKEditor will try to detect the correct path.\r
75 $CKEditor->basePath = '../../';\r
76 \r
77 // Set global configuration (will be used by all instances of CKEditor).\r
78 $CKEditor->config['width'] = 600;\r
79 \r
80 // Change default textarea attributes.\r
81 $CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10);\r
82 \r
83 // The initial value to be displayed in the editor.\r
84 $initialValue = '<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>';\r
85 \r
86 // Create the first instance.\r
87 $code = $CKEditor->editor("editor1", $initialValue);\r
88 \r
89 echo $code;\r
90 ?>\r
91                                 <br />\r
92                                 <label>Editor 2:</label>\r
93 <?php\r
94 // Configuration that will only be used by the second editor.\r
95 $config['toolbar'] = array(\r
96         array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),\r
97         array( 'Image', 'Link', 'Unlink', 'Anchor' )\r
98 );\r
99 \r
100 $config['skin'] = 'v2';\r
101 \r
102 // Create the second instance.\r
103 echo $CKEditor->editor("editor2", $initialValue, $config);\r
104 ?>\r
105                 <p>\r
106                         <input type="submit" value="Submit"/>\r
107                 </p>\r
108         </form>\r
109         <div id="footer">\r
110                 <hr />\r
111                 <p>\r
112                         CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>\r
113                 </p>\r
114                 <p id="copy">\r
115                         Copyright &copy; 2003-2012, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico\r
116                         Knabben. All rights reserved.\r
117                 </p>\r
118         </div>\r
119 </body>\r
120 </html>\r