Home  >  Article  >  CMS Tutorial  >  Which editor is used for PHPCMS?

Which editor is used for PHPCMS?

Guanhui
GuanhuiOriginal
2020-06-19 17:34:022757browse

Which editor is used for PHPCMS?

# Which editor does PHPCMS use?

PHPCMS uses the CKEditor editor. CKEditor is a new generation of FCKeditor, a re-developed version. This editor is one of the best online web text editors in the world because of its amazing Its performance and scalability make it widely used in major websites.

Integrate CKEditor

There are several ways to integrate CKEditor into your web page. Here we introduce the most commonly used implementations method.

Step One: Load CKEditor

CKEditor is a JavaScript application, you only need to include a file reference in your web page to load it.

If you have installed CKEditor in the "ckeditor" directory of your website, you can refer to the following example:

<head>
...
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
</head>

Load in the above way, the CKEditor JavaScript API is ready and can be used. .

Step 2: Create an editor instance

CKEditor works like a text area (textarea) in your web page. It provides a simple and easy-to-write user interface and layout. and rich text input areas. But it is not easy to achieve the same effect with a text area. It requires the user to enter html code.

However, in fact, CKEditor still uses a text area to transfer its data to the server. This text area is invisible to the user. Therefore, you must create and edit an instance. First create an instance:

<textarea id="editor1"></textarea>

Note that if you want to load some data into the editor, such as reading data from a database, you only need to put the data in Just inside a textarea, like in the example above. In this example, we have named the textarea "editor1". This name will be used in server operations when receiving POST submitted data. To start using the CKEditor Javascript API, we use an editor instance to "replace" this ordinary text area (textarea). To do this, we must add the following JavaScript code:

<script type="text/javascript">
CKEDITOR.replace( &#39;editor1&#39; );
</script>

The above script block only Can be included after the 4750256ae76b6b9d804861d8f69e79d3 tag of a web page. You can also run this replacement process within the 93f0f5c25f18dab9d176bd4f6de5d30e tag, but in this case, you must make sure that the DOM has been loaded. This can usually be written in the window.onload event (the DOM must have been loaded at this time) :

<script type="text/javascript">
window.onload = function()
{
CKEDITOR.replace( &#39;editor1&#39; );
};
</script>

Step 3: Save editor content data

As previously described, the editor works like a text area (textarea), so when submitting an editor instance that contains When forming a form, its data will also be passed very simply, using the name of the textarea as the key to receive the data. For example, according to the above example, in PHP we need to process data like this:

<?php
$editor_data = $_POST[ &#39;editor1&#39; ];
?>

Client-side data processing In some applications (such as ajax applications), all data needs to be processed on the client side. It then has its own way of sending the data to the server, in these cases using the CKEditor API is enough to easily get the content in the editor instance. For example:

<script type="text/javascript">
var editor_data = CKEDITOR.instances.editor1.getData();
</script>

Recommended tutorial: "PHPCMS Tutorial"

The above is the detailed content of Which editor is used for PHPCMS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn