Online edition with TinyMCE

Using TinyMCE, you can directly create web pages on your site by logging in to any computer. Create static pages using a template, a reusable template into which the content of a written article is inserted.

Choosing a template from the list for each article or changing it to an already published article is even quite simple - an option ignored by most CMS, although useful for contextual design.

We chose one of the most popular online publishers - TinyMCE. It is written in JavaScript and runs on a browser. He can fit into the CMS and is the default Wordpress editor. We will associate it with scripts designed to integrate new pages on the site. Ideally news.

Although this article is primarily pedagogical, it is accompanied by a complete enough demonstration to be functional and usable on your site. Then we will develop a more professional product... But also free.

This demo from the beginning has a tool for creating URLs consisting of keywords to optimize the site for search engines, while some widespread CMS, such as Joomla, can only do this with a plugin!

How does it work

The page creation system consists of the following files:

Principles

TinyMCE works by associating editing functions with a form object, a text area. Other form objects are added to this demonstration for title, template selection.

A template is an HTML or PHP page that contains markers for inserting title and text:

For the name of the PHP variable:

<?php title="montitre"; ?> 

For layer content:

<div id="content">  
</div>

It will be easy to create a new template from the proposed template.

When the user clicks the Save button, the values ​ ​ or content of the form objects are passed to the store.php script by the Ajax script. The PHP script does the following:

  1. It calls the titleconvert.php script to create the URL.
  2. It loads the pattern whose name was given to it by writing it under the filename generated by titleconvert, a name that is a sequence of keywords without accents or uppercase letters.
  3. Instead, the title and text of the article are inserted.
  4. The article is then published and must be linked to the homepage.

Edit an already published article

To resume information on an already published page, the same powerful rational expressions are used as for storing data on a new page formed by a copy of the template.

The advantage of this system is that our online editor does not need to store texts either in the database or in XML files, they are stored directly on the pages and repeated on the pages for editing .

Future developments

In order for this tool to be used in production, it must be designed and have at least one list of published articles to facilitate its editing. You also need to automatically link articles on the home page of the site.
Software like Wordpress only links recent articles on the home page. Such a solution is easy to implement.

In addition, you can add many tools to it: RSS stream generator, sitemap, etc. This will be the subject of further publication.

It is also possible to connect the editor to the database not for the content of articles, but for related information such as categories, tags, etc. This can also become the subject of another demonstration .

Using the demo

  1. Extract the content from the archive and post it to your site.
  2. Launch install.php to create a login and password.
  3. It will then be automatically deleted. You must download this file again to use it later.
  4. Run editor.php
  5. Enter the title and content, select the template (they are all identical in the demo).
  6. Add article link to homepage.

Download Scripts

The archive contains the TinyMCE distribution, PHP scripts, and sample templates .

Discussion board

MCE Editor Installation Question

06-07-2011 22:48:23

Claude

Good evening, I am especially interested in the tuto script published on the site for my association, I created a script to send e-mail and mail to members with tiny as publisher, but I did not find anywhere on the Internet tuto or script to load the page template or resume the template, to change it, it seems to me that your script meets all my expectations, but impossible to test I only have a bunch of error messages, which, it seems to me, are associated with the login part of the example: (!) Notice: Undefined index: login in C :\Wamp\www\SOLMCE\editor.php on line 9 Call Stack # Time Memory Function Расположение 1 0.0006 693272 {main} () ..\editor.php: 0 (!) Notice: Undefined index: password in C :\Wamp\www\SOLMCE\editor.php on line 10 Call Stack # Time Memory Function Расположение 1 0.0006 693272 {main} () ..\editor.php: 0 (!) Deprecated: Function session_register () devalued in C :\Wamp\www\PJ TinyMCE\original script\authorize.php on line 47 Call Stack # Time Memory Function Location 1 0.0004 692720 {main} () ..\editor.php: 0 2 0.0011 724608 authorize () ..\editor.php: 19 Thank you for asking me Good evening Claude
07-07-2011 08:41:42

webmaster

Hi Have you run the install.php script to create an account? This prevents anyone from editing on your site...
07-07-2011 08:58:44

Claude

Hello, yes, of course, I went through the installation, I loaded the script into different directories several times and installed the same problem, stupid question, why did you plan such an important protection system for the introductory tuto?? You yourself say that this is not a tool of production. I would like to be successful because that is what I really lack for my application Thank you for your response Good afternoon
07-07-2011 18:00:13

webmaster

Obviously, it causes problems:
$ulogin= $_SESSION["login"];
$upass= $_SESSION["password"];
So the $ _ SESSION variable is not initialized, and the session is not open, which can be checked with the $ _ SESSION dump. Does your configuration support sessions? Security integration is necessary because some users can use the software as is.
08-07-2011 08:25:40

Claude

Hello, sorry to bother you, I just put the script right on my hosting and installation is no problem, this is my local wamp that is in question. Happy day and thanks again for Claude's performance

Display text color

26-01-2011 14:29:40

webmaster

Hello, I could not reproduce the problem. Text conversion is done by the TinyMCE editor, the script simply calls the editor API. If necessary, the file_put_contents () function in the store.php file can change the text.
$n = file_put_contents($filename, $body);
You can add a parameter to force binary mode...
$n = file_put_contents($filename, $body, FILE_BINARY );
Similarly, the loading function in retrieve.php can be changed:
$content = @file_get_contents($page, FILE_BINARY);
I cannot check it, as for me the content is honestly returned.
26-01-2011 12:44:28

Nicko

Hi, thanks for the script first. However, I am faced with a problem: after editing the color text and saving it. The default text color appears black when you open the .php file in a browser. I noticed that the code has/. If I delete them, the color will reappear. Ex: <p> <span style = "color: # f0000;"> test in red </span> <span stan =\" color: # 000080 ;\"> test in blue </span> </p> ---> red appears, no/no blue. You have a solution, I was looking, but nothing can be done... Thanks!
26-01-2011 15:31:56

Nicko

Hi, thanks for the response! But unfortunately it doesn't work... I don't understand.
26-01-2011 16:01:32

webmaster

You can try reconfiguring TinyMCE. Delete to see urldecode in store.php:
$content = urldecode($a["content"]);
becomes:
$content = $a["content"];
You also need to know if the text has already been changed in the saved file or when overwriting it. To do this, you need to see the contents of the file in the editor.
26-01-2011 17:07:13

Nicko

In fact, the change takes place from the moment of backup. I wanted to put a function to take off the slash, but I don't mean too much where I really need to find it.
26-01-2011 17:37:42

Nicko

FYI, I also had the CKEditor online editing script installed and even issues. I tested them separately by downloading and they work properly.
26-01-2011 18:52:14

webmaster

Changes occur in store.php on the $ content variable before this line:
$body = $head.'<div id="content">'.$content.'</div>'.$parts[1];
In this case, it would be better to use the stripcslashes function after rebooting via retrieve.php
$content = @file_get_contents($page);
$content = stripslashes($content);
26-01-2011 21:06:24

Nicko

Well, I added well: $ content = stripslashes ($ content); после $ content = @ file _ get _ contents ($ page); at retrieve.php, but it really doesn't want to! In any case, thanks for the answers and efficiency!
26-01-2011 21:20:28

Nicko

Oh, yeah! I didn't have a test, I have something to do! When I edit my simply saved page using the tinymce editor. The text color displays correctly. with code: <p> <stran style = "color: # f0000;"> Color test <br/> </stran> </p> But if I show the created page in the browser, the color disappears... The code becomes: <span # ff0000 ;\="" style = ""> Color test <br/> </span> (no color style!)
27-01-2011 09:39:32

webmaster

Can you tell me what the PHP version is? I get multiple requests for the same problem over several days when the script works well for me, also I suspect a change in PHP functions.
27-01-2011 10:04:56

Nicko

Hello, So PHP Version: PHP Version 5.2.6-1 + lenny9
27-01-2011 17:33:04

webmaster

After several tests on different hosting, I do the following: Replace in store.php:
$n = file_put_contents($filename, $body);
by:
$nfile = fopen($filename, 'w'); 
$n = fwrite($nfile, stripslashes($body)); 
fclose($nfile);
I will post a new version.
27-01-2011 18:39:20

Nicko

Well, it's perfect! It works! Thanks very much! Nico.