Use templates with CKEditor
Just like we did with TinyMCE, we will show the use of the WYSIWYG CKEditor online editor with templates and the automatic generation of a file name from the keywords contained in the article header.
The template is selected when the part is created and can be modified by editing an already saved part, selecting a file from the drop-down list. You can add your own templates to the catalog.
How does it work
The basic system consists of a series of scenarios. This is intended to be developed by the webmaster according to his needs .
In particular, you should create different templates .
- CKEditor is the latest version of the online editor.
- Our interface, which is an HTML page that integrates CKEditor and combines buttons with basic functions.
- store.php creates a file for the edited article.
- retrieve.php finds the content of the article in a file created using this interface.
- The Ajax anaa.js framework allows you to save an article without leaving the current interface or work.
- titleconvert.php loaded by store.php to create the filename.
- Three examples of templates in the templates subdirectory.
Use template
- Extract the content from the archive and post it online on your site or test it locally in the Wamp, Xamp directory or equivalent.
- Launch install.php to create a login and password.
- It needs to be erased and returned to the Internet if you want to change your password .
- Download editor.php page
- Enter a title of one or more words.
- Select a template.
- Enter text and save.
- Add a link to an article on your site.
Display
For this very simple demonstration, we use only three files:
- demo-fr.php. Demonstration.
- pagebuild.php. The page that displays the result.
- pagedemo.txt. The file to be created.
The main code is as follows
1) Enables the editor. Place this code in the HEAD section of the page:
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
2) Add a form displaying the submit button to save the text:
<form action="pagebuild.php" method="post" target="_top">
<input type="hidden" name="page" value="demo-fr.php" >
<input type="submit" value="Sauver le contenu">
</form>
6) Creating an editor instance. The code is inserted into the form, into the page body:
<textarea cols="80" id="editor1" name="editor1" rows="10">Vide</textarea>
<script type="text/javascript">
//<![CDATA[
var editor = CKEDITOR.replace( 'editor1' );
//]]>
</script>
When you click on the button, the pagebuild.php script will take the text you entered, which FCKeditor assigns to the variable, and is going to save it to a file.
The field in the hidden demo passes the URL of the editor page for the script to load.
The archive contains the CKEditor distribution, interface and PHP scripts, as well as sample templates.
Q. Use CKEditor
nikolas83210
webmaster
<html> <head> <title>Document sans-titre</title> <meta charset=utf-8> </head> <body> <?php if (isset( $_POST )) $postArray = &$_POST ; // 4.1.0 or later else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0 $fname="fck/pagedemo.txt"; $nfile = fopen($fname, "w"); if($nfile != false) { foreach ($postArray as $sForm => $value ) { $yourText = $value ; fwrite($nfile, $yourText); } fclose($nfile); } echo "You have written:<br/></br/>"; echo $yourText . "<br/></br>"; ?> <form action="demo-fck.php" method="post" target="_parent"> <input type="submit" name="envoi" value="Revenir à l'éditeur"> </form></body> </html>For the French text, another file was created that did not affect the article. It will be updated so that you can download all the necessary files.
nikolas83210
Thanks bcp for the response, it will be good. on the other hand, i have been trying for three days to find a solution for my pb, if you have an idea it will help me bcp bcp. I try to save some forms of fkeditor to bdd and nothing happens, it doesn't update in my bdd but there is no error message, this is what will be from my database, I created a news table with text field 1 in the textlong, in short, here's: I have two files: I have two files: formula aire.php
<? php include («FCKeditor/fceditor.php»);?> <html> <head> <title> Newscast </title> </head> <body> <form name = "editNews" method =" POST" action = "savedata.php"> <? php $ db = mysql_connect ('mabase', 'user', 'pass') or die ('Unable to connect'); if (! mysql _ select _ db ("mabase," $ db)) echo "Error: cannot select base <br>"; $ select = "SELECT text 1 FROM news"; $ req = mysql_query ($ select, $ db) or die ("Error:» .mysql _ error ()) while ($ row = mysql_fetch_array ($ req)) {echo '<tr>'; $ text = $ row [0];} $ oFCKeditor = new FCKeditor ("FCKeditor1"); $ oFCKeditor -> BasePath = 'FCK editor/' ;//Index to folder path FCKeditor $ oFCKeditor -> Width = "78%"; $ oFCKeditor -> Height = "50%"; $ oFCKeditor -> Value = $ text; $ $ o FCKeditor-> Create ();?> <br> <input type = "submit" value = "Submit"> </form> </body> </html> then savedata.php <? $ db = mysql_connect ('mabase', 'user', 'pass') or die ('Unable to log in'); if (! mysql _ select _ db ("mabase," $ db)) echo "Error: Unable to select base <br>"; $ updateNews = $ _ POST ["FCKeditor1"]; $ mysqlQuery = "UPDATE 'news" SET texte1 = "$ updateNews" "; mysql_query ($ mysqlQuery, $ db) или die ('MySQL error:' .mysql _ error ());?>
please, I have been on fceditor for three days now
webmaster
nikolas83210
webmaster
nikolas83210
nikolas83210
nikolas83210
Step failed, help
Titof
<?php if (isset( $_POST )) $postArray = &$_POST ; // 4.1.0 or later else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0 $fname="fck/pagedemo.txt"; $nfile = fopen($fname, "w"); if($nfile != false) { foreach ($postArray as $sForm => $value ) { fwrite($nfile, $value); } fclose($nfile); } ?>It would be great if I could find help in advance thanks Titof
webmaster
mobilesong
user10
webmaster
CKeditor and bdd
bubul
<form method="post" name="editor" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Titre:</td> <td><input type="text" name="titre" value="<?php echo $row_Recordset2['titre']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Txt:</td> <td><input type="text" name="txt" value="<?php echo $row_Recordset2['txt']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td> <?php $oFCKeditor = new FCKeditor('editor') ; $oFCKeditor->BasePath = '../fckeditor/'; $oFCKeditor->Value = $row_Recordset2[txt]; $oFCKeditor->Create() ; $oFCKeditor->Name='txt'; ?></td> </tr> <input type="submit" value="Mettre à jour"> </table> <input type="hidden" name="MM_update" value="editor"> <input type="hidden" name="id" value="<?php echo $row_Recordset2['id']; ?>"> </form>Thanks very much!!!
webmaster