Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[HOW TO] Add WYSIWYG Editor to Your Modifications
Mythotical
Join Date: Jun 2004
Posts: 1,428

 

Booneville, AR, USA
Show Printable Version Email this Page Subscription
Mythotical Mythotical is offline 11-22-2009, 10:00 PM

I do this as a free service, I am a student however and all donations are welcome. You can click on the Paypal icon to make a donation:

I will add instructions for pulling data when editing a file.


This article was done for vB 3.5 and later, I now bring you the article for vB 4.0 in regards to the editor in modifications.

Working Versions: Currently 4.1.10
Testing Versions: NONE

This tutorial will provide you the proper method for including the WYSIWYG editor in your modifications. I have tested this and it works so following this tutorial will provide a working editor. You are welcome to tweak it to your liking so that you get different output's or vice versa.

Lets begin.

Step 1. Make sure you have already added the row to your database table. The new row to add is:
PHP Code:
`messagevarchar(255
You can alter that to be messagearea, message, description, etc and it will work just the same.

Step 2. Open your template containing your form.
Step 3. Install the provided plugin xml file.
Step 3. Add the following lines of code.

Now add this in place of your opening form tag (Remember to change your action to your correct file):
HTML Code:
<form class="vbform block" action="file.php" method="post" name="vbform" onsubmit="return vB_Editor['{vb:raw editorid}'].prepare_submit(0, 0)">


    <div class="blockbody formcontrols">
        <div class="section">
        

            {vb:raw messagearea}


        </div>
    </div>

    <div class="blockfoot actionbuttons">
        <div class="group">
                <input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
                <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
                <input type="hidden" name="do" value="postsomething" />
                <input type="submit" class="button" name="sbutton" id="{vb:raw editorid}_save" value="{vb:rawphrase submit}" accesskey="s" tabindex="1" />
                <input type="submit" class="button" name="preview" value="{vb:rawphrase preview_post}" accesskey="r" tabindex="1" />
        </div>
    </div>


</form>
Step 4. Add the following to your php file.

Open the file you wish to add your editor to (Make sure you have this code in the area where your template containing the editor is to be called):
PHP Code:
require_once(DIR '/includes/functions_editor.php');
require_once(
DIR '/includes/functions_bigthree.php');

$editorid construct_edit_toolbar('',1,'signature',1,1,($vbulletin->userinfo['userid'])); 
Then edit your template register and add the following:
PHP Code:
$templater->register('editorid'$editorid);
$templater->register('messagearea'$messagearea); 
Add this line to your php file after you define special templates, global templates, etc:
PHP Code:
define('GET_EDIT_TEMPLATES'true); 
Add these to your specialtemplates:
PHP Code:
$specialtemplates = array('smiliecache','bbcodecache'); 
Step 5. Save and close your file, upload and test. Make sure you saved your template as well.

This is a short article/tutorial and I hope many find it useful. Even though I did not come up with the code or discover the code, I am happy to help others out as I was helped out.

Preview provided at attachments.
Attached Images
File Type: jpg editor.jpg (20.4 KB, 0 views)
File Type: png file.png (3.5 KB, 0 views)
Attached Files
File Type: xml vbulletin-plugins.xml (414 Bytes, 123 views)
Reply With Quote
  #22  
Old 12-20-2009, 12:11 PM
xman_79's Avatar
xman_79 xman_79 is offline
 
Join Date: Jun 2006
Location: Romania
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not understand why you use

PHP Code:
define('GET_EDIT_TEMPLATES'true); 
The php file

PHP Code:
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT''name_of_your_script');
define('CSRF_PROTECTION'true);

$phrasegroups = array('posting');

$specialtemplates = array('smiliecache','bbcodecache',);

$globaltemplates = array(
    
'newpost_disablesmiliesoption',
    
'newpost_usernamecode',
    
'editor_toolbar_on',
    
'editor_clientscript',
    
'editor_jsoptions_font',
    
'editor_jsoptions_size',
    
'editor_smilie',
    
'editor_smiliebox',
    
'editor_smiliebox_row',
    
'editor_smiliebox_straggler',
    
'editor_css',
    
'editor_smilie_category',
    
'editor_smilie_row',
    
'editor_toolbar_colors',
    
'editor_toolbar_fontname',
    
'editor_toolbar_fontsize',
    
'bbcode_code_printable',
    
'bbcode_html_printable',
    
'bbcode_php_printable',
    
'bbcode_quote_printable',
    
'bbcode_code',
    
'bbcode_html',
    
'bbcode_php',
    
'bbcode_quote',
    
'bbcode_video',
);

require_once(
DIR '/includes/functions_editor.php');

$editorid construct_edit_toolbar(''0'signature'11false);


$templater vB_Template::create('MY_EDITOR_TEMPLATE');
    
$templater->register('editorid'$editorid);
    
$templater->register('messagearea'$messagearea);
$myeditortemplate $templater->render(); 
I use the editor to about 10 hacks, I have no problem.
Reply With Quote
  #23  
Old 12-23-2009, 06:27 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The part that I use above is sticking with code ethics basically, it saves on lines of code per file and does the same exact thing as this does:

PHP Code:
$globaltemplates = array( 
    
'newpost_disablesmiliesoption'
    
'newpost_usernamecode'
    
'editor_toolbar_on'
    
'editor_clientscript'
    
'editor_jsoptions_font'
    
'editor_jsoptions_size'
    
'editor_smilie'
    
'editor_smiliebox'
    
'editor_smiliebox_row'
    
'editor_smiliebox_straggler'
    
'editor_css'
    
'editor_smilie_category'
    
'editor_smilie_row'
    
'editor_toolbar_colors'
    
'editor_toolbar_fontname'
    
'editor_toolbar_fontsize'
    
'bbcode_code_printable'
    
'bbcode_html_printable'
    
'bbcode_php_printable'
    
'bbcode_quote_printable'
    
'bbcode_code'
    
'bbcode_html'
    
'bbcode_php'
    
'bbcode_quote'
    
'bbcode_video'
); 
Just one line of code instead of 10-15 lines to call all those templates.

In all honesty, you don't have to call these templates as you have done:
PHP Code:
    'bbcode_code_printable'
    
'bbcode_html_printable'
    
'bbcode_php_printable'
    
'bbcode_quote_printable'
    
'bbcode_code'
    
'bbcode_html'
    
'bbcode_php'
    
'bbcode_quote'
    
'bbcode_video'
From what I have learned is that each one of those templates is already cached and called when you use the editor.
Reply With Quote
  #24  
Old 12-24-2009, 08:21 AM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello Steve,

I've problem including the editor in my mod. See the attached images to understand what I mean. The first one is without including "...GET_EDIT_TEMPLATES..." in my php file, the second is with this.

http://www.microhellas.com/dev4/auct...do=addedititem

I'm also getting that yellow triangle:
Code:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Date/Time: Thu, 24 Dec 2009 10:18:59 UTC
 
Message: Το 'vB_XHTML_Ready' has not been assigned
Line: 11
Character: 1
Code: 0
URI: http://www.microhellas.com/dev4/clie...ditor.js?v=400
Thank you in advance
Maria

PS- I found the solution

At the very top of the template,

After:
Code:
<![CDATA[
and Before:
Code:
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
Must be:
Code:
{vb:stylevar htmldoctype}
But that dammit triangle still exists.

Merry Christmas Steve (and to all surfers of course).
Maria
Attached Images
File Type: jpg without_get_edit_templates.jpg (20.3 KB, 0 views)
File Type: jpg with_get_edit_templates.jpg (21.5 KB, 0 views)
Reply With Quote
  #25  
Old 12-24-2009, 05:16 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great to hear Maria.
Reply With Quote
  #26  
Old 12-26-2009, 08:49 AM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello Steve,

In view mode the text loses some formatting (in my case bullets). See attachment 1 which is in edit mode. Bullet list has been saved correctly. Now the 2nd attachment. Even if the text coloring is ok, the bullet list appears as normal text lines.

The code that I've wrote:

PHP file
Code:
// Format Bodytext
$bodytext = $item["bodytext"];
$bodytext = convert_wysiwyg_html_to_bbcode($bodytext);
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$bodytext = $bbcode_parser->parse($bodytext, $post['allowsmilie']);
Template
Code:
<tr>
   <td colspan="4" class="blockrow" align="left" width="100%">
      {vb:raw bodytext}
   </td>
</tr>
Thank you
Maria
Attached Images
File Type: jpg editmode.jpg (37.7 KB, 0 views)
File Type: jpg viewmode.jpg (15.6 KB, 0 views)
Reply With Quote
  #27  
Old 12-26-2009, 05:07 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Maria, I will get it altered in the article.
Reply With Quote
  #28  
Old 02-04-2010, 06:54 PM
mikey1991's Avatar
mikey1991 mikey1991 is offline
 
Join Date: Oct 2008
Location: United Kingdom
Posts: 654
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Steve, I know you posted this article for vB3, or one was posted, I just cannot find it. Any help?
Reply With Quote
  #29  
Old 02-05-2010, 01:04 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mikey1991 View Post
Steve, I know you posted this article for vB3, or one was posted, I just cannot find it. Any help?
Here is the article, not written by me: Add Editor to Your Mods
Reply With Quote
  #30  
Old 02-05-2010, 02:57 PM
mikey1991's Avatar
mikey1991 mikey1991 is offline
 
Join Date: Oct 2008
Location: United Kingdom
Posts: 654
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great, thanks alot steve, appreciate that.
Reply With Quote
  #31  
Old 02-15-2010, 08:20 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mikey1991 View Post
Great, thanks alot steve, appreciate that.
Your welcome.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:22 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04679 seconds
  • Memory Usage 2,384KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_code
  • (1)bbcode_html
  • (9)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (5)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (7)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete