Logo name

Ipb 2.1:Using Editors Class

From IpbWiki

  • Currently0.00/5
Jump to: navigation, search

IPB 2.1 comes with a handler for displaying a text editor. There are two editors to choose from; Rich Text Editor (WYSIWYG) and a standard BBCode editor. The Rich Text Editor is only available when using IE6, Mozilla and Firefox due to the javascript which controls this editor and the lack of compatibility with other browsers. Safari and Opera are due to add support and the editor classes will be updated when they do.

There are two main functions:

CODE
show_editor ( $text, $form_field )

This returns the HTML code for the editor to use in your skins, etc.

CODE
process_raw_post( $form_field )

This returns the raw post. In the case of the rich text editor, it parses the WYSIWYG HTML into BBCode tags. (For example: Bold becomes Bold) so this function will always return raw BBCode tags.

First off, we include the handler in our script.

CODE
//-----------------------------------------
// Load and config the std/rte editors
//-----------------------------------------

require_once( ROOT_PATH."sources/handlers/han_editor.php" );
$han_editor = new han_editor();
$han_editor->ipsclass =& $this->ipsclass;
$han_editor->init();

To generate the HTML for the editor:

CODE
$editor_html = $han_editor->show_editor( $raw_post, 'Post' );

$raw_post is either raw HTML for the rich text editor or raw BBCode tagged text when using the standard editor. (See the document on the BBCode parser for more information)
'Post' is the name of the form field you wish use. In this case it'll return $_POST['Post'].

To process the editor's text into tagged BBCode text:

CODE
$post = $han_editor->process_raw_post( 'Post' );

'Post' is the name of the form field you used when displaying the editor.

To use the HTML generated by editor class for displaying the actual editor (in our example; $editor_html) you'll need to use it like this:

HTML
<form id='postingform' onsubmit='return ValidateForm()' action="$url" method="post" name="REPLIER">
{$editor_html}
<br /><input type="submit" value="Post" /></div>
</form>

The form tag MUST have: id='postingform' onsubmit='return ValidateForm()' otherwise the editor will fail.

This page was last modified on 11 November 2006, at 15:19.  This page has been accessed 2,970 times.  Content is available under GNU Free Documentation License 1.2Disclaimers