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
  #12  
Old 12-13-2009, 04:31 PM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Steve M View Post
Hmmmm, I opened it in IE8 but I get no error report. Let me check a few things and I'll post back.

Your welcome.
Thank you for taking the time to help me. If you want, I've post the full product at:
https://vborg.vbsupport.ru/showthread.php?t=230112
but I think that I follown your instructions step by step.

Maria
Reply With Quote
  #13  
Old 12-13-2009, 04:39 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Apparently that error triangle is from subscriptions portion. Might be a bug with vB. I have tried to replicate it and even tried adding new tickets and such, still no error on my end. Sorry I couldn't provide more info than that. I'm actually sitting here scratching my head over it. LOL
Reply With Quote
  #14  
Old 12-13-2009, 04:42 PM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Steve M View Post
Apparently that error triangle is from subscriptions portion. Might be a bug with vB. I have tried to replicate it and even tried adding new tickets and such, still no error on my end. Sorry I couldn't provide more info than that. I'm actually sitting here scratching my head over it. LOL
Ok:-)) Let to see if anybody report it in my post. My site is not the stablest on the net, actually it has nothing, so maybe something else causes it.

take care
Maria
Reply With Quote
  #15  
Old 12-13-2009, 04:43 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Possibly, if you need help narrowing down where it may come from, I'll gladly help you out.
Reply With Quote
  #16  
Old 12-14-2009, 02:45 PM
AndrewD AndrewD is offline
 
Join Date: Jul 2002
Location: Scotland
Posts: 3,486
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've spent today tearing my hair out in updating the wysiwig editor from vb3.8 to v4.0 in a product I handle. Eventually, I tried reproducing the problem using the code suggested here, and the same problem arose. Basically, when in full WYSIWIG mode, the text entered into the message box is not being returned to the server, unless one first refreshes the page. In standard mode (obtained either by using the control switch in the editor, or by setting the appropriate vb options), everything works fine. This means that the problem cropped up with IE and Firefox but not with Google Chrome or Safari, which always use the standard editor.

For some reason, though, this problem does not seem to crop up in, e.g., the standard VB editpost code.

Possibilities are that I've made a mistake (quite possible...), or there's a bug in vb4.0 (I'm testing with RC2), or there's a switch/file that we're overlooking.

The attached files are, as far as I can tell, a straight copy of the material posted at the start of this article, within a script that simply keeps re-presenting the form along with a record of the message entered by the user the previous time round. I'd be very grateful if someone can independently test this, and let me know if I'm going crazy or not.

The two files are a php script to be loaded into the forum directory, and a template.
Attached Files
File Type: php aaaatest.php (1.2 KB, 70 views)
File Type: txt aaaatest.txt (2.9 KB, 69 views)
Reply With Quote
  #17  
Old 12-14-2009, 03:07 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I noticed 2 things.

First:
PHP Code:
$retvars .= "message:".$vbulletin->GPC['message'].":<br />"
You have that but not registered it for use in the template.

Second:
In your template I notice you have the form pointing to the same file that you are using to fill out this form. Am I mistaken that maybe you didn't give the process form location.

Also I noticed that you don't have this in your file:
PHP Code:
define('GET_EDIT_TEMPLATES'true); 
With your submit button, try this instead:
HTML Code:
<input name="submit" class="button" type="submit" id="save" value="submit" />
Reply With Quote
  #18  
Old 12-14-2009, 03:42 PM
AndrewD AndrewD is offline
 
Join Date: Jul 2002
Location: Scotland
Posts: 3,486
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the suggestions, see below.

Quote:
Originally Posted by Steve M View Post
I noticed 2 things.

First:
PHP Code:
$retvars .= "message:".$vbulletin->GPC['message'].":<br />"
You have that but not registered it for use in the template.

Also I noticed that you don't have this in your file:
PHP Code:
define('GET_EDIT_TEMPLATES'true); 
sorry, Steve, not true - both are done (line 7 and 45 in the php file)

Quote:
Originally Posted by Steve M View Post
Second:
In your template I notice you have the form pointing to the same file that you are using to fill out this form. Am I mistaken that maybe you didn't give the process form location.
this was intended to be a simpe demo of the problem, and the script is designed to return to itself, report what was filled in the message box, and then re-present the editor. So, there's no error with that, and the same issue presents itself in the (much more complex) product code I'm working on.


Quote:
Originally Posted by Steve M View Post
With your submit button, try this instead:
HTML Code:
<input name="submit" class="button" type="submit" id="save" value="submit" />
This makes no difference. The message box contents are being correctly picked up in standard editor mode but not in wysiwig mode.
Reply With Quote
  #19  
Old 12-14-2009, 03:56 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then you have completely contradicted what you said earlier about it not working. If you can't show me how this is being used in the complexity that you are trying to make it work then I can be of no help. Lastly there apparently is an error as you stated earlier and now you state there is no error. Overall you have your code set so without more info then I am of no help any further. Sorry.
Reply With Quote
  #20  
Old 12-14-2009, 04:18 PM
AndrewD AndrewD is offline
 
Join Date: Jul 2002
Location: Scotland
Posts: 3,486
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Steve M View Post
Then you have completely contradicted what you said earlier about it not working. If you can't show me how this is being used in the complexity that you are trying to make it work then I can be of no help. Lastly there apparently is an error as you stated earlier and now you state there is no error. Overall you have your code set so without more info then I am of no help any further. Sorry.
I'll try to be a little clearer, since I didn't intend to seem to contradict myself.

The supplied attached php + template is a straightforward implementation of the code given in the first post, intended to demonstrate the problem.

With this demo code, and with the more complex product implementation, the contents of the editor message box are correctly returned (with all browser choices) when the editor is set to standard mode but not when it is set to wysiwig mode. I can consistently reproduce this problem on my own system. I am asking for someone else to attempt to reproduce it on another, so that I can be sure that it is/is not a bug in my coding or in the vb infrastructure.
Reply With Quote
  #21  
Old 12-14-2009, 04:43 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AndrewD View Post
I'll try to be a little clearer, since I didn't intend to seem to contradict myself.

The supplied attached php + template is a straightforward implementation of the code given in the first post, intended to demonstrate the problem.

With this demo code, and with the more complex product implementation, the contents of the editor message box are correctly returned (with all browser choices) when the editor is set to standard mode but not when it is set to wysiwig mode. I can consistently reproduce this problem on my own system. I am asking for someone else to attempt to reproduce it on another, so that I can be sure that it is/is not a bug in my coding or in the vb infrastructure.
Ok gotcha, I will test it out and check for you.

--------------- Added [DATE]1260816961[/DATE] at [TIME]1260816961[/TIME] ---------------

Ok tested it, you had a few issues in your template but I changed them to match my site mainly and it worked.

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" id="vbulletin_html">

<head>
<!-- BEGIN TEMPLATE: headinclude -->
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta id="e_vb_meta_bburl" name="vb_meta_bburl" content="/vb40/" />
<base href="/vb40/" /><!--[if IE]></base><![endif]-->
<meta name="generator" content="vBulletin 4.0.0 Release Candidate 2" />


		<meta name="keywords" content="vbulletin,jelsoft,forum,bbs,discussion,bulletin board" />
		<meta name="description" content="This is a discussion forum powered by vBulletin. To find out about vBulletin, go to http://www.vbulletin.com/ ." />


<script type="text/javascript" src="clientscript/yui/yuiloader-dom-event/yuiloader-dom-event.js?v=400rc2"></script>
<script type="text/javascript" src="clientscript/yui/connection/connection-min.js?v=400rc2"></script>
<script type="text/javascript">
<!--
	var SESSIONURL = "";
	var SECURITYTOKEN = "1260802232-afa16d4d00cd73257e7c03c916068b2ffef8d4c5";
	var IMGDIR_MISC = "images/misc";
	var IMGDIR_BUTTON = "images/buttons";
	var vb_disable_ajax = parseInt("0", 10);
	var SIMPLEVERSION = "400rc2";
	var BBURL = "/vb40";
// -->
</script>

<script type="text/javascript" src="clientscript/vbulletin-core.js?v=400rc2"></script>


<link rel="stylesheet" type="text/css" href="clientscript/yui/reset-fonts/reset-fonts.css" />
<link rel="stylesheet" type="text/css" href="css.php?styleid=1&amp;langid=1&amp;d=1260798350&amp;td=ltr&amp;sheet=vbulletin.css,popupmenu.css,vbulletin-chrome.css,components.css,vbulletin-formcontrols.css,editor.css" />


<!-- END TEMPLATE: headinclude -->


<script type="text/javascript" src="clientscript/vbulletin-editor.js?v={vb:raw vboptions.simpleversion}"></script>

<link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}vbulletin-formcontrols.css" />
<link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}editor.css" />
<link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}bbcode.css" />


</head>
<body>

{vb:raw header}

{vb:raw navbar}

{vb:raw retvars}

<form class="vbform block" action="aaaatest.php" method="post" name="vbform" onsubmit="return vB_Editor['{vb:raw editorid}'].prepare_submit(this.inputname.value, {vb:raw vboptions.postminchars})">
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<div class="wysiwyg_block">
<div class="blockbody formcontrols">
<div class="blockrow">
	{vb:raw messagearea}
</div>
</div>
</div>

<div class="blockfoot actionbuttons">
<div class="group">
<input name="submit" class="button" type="submit" id="{vb:raw editorid}_save" value="submit" />
</div>
</div>

</form>
{vb:raw footer}
</body>
</html>
--------------- Added [DATE]1260816996[/DATE] at [TIME]1260816996[/TIME] ---------------

It all had to do with link tags and script tags.

EDIT AGAIN:
Tested again with your code and it worked that time so looks like it was in the template.

The way you have it, I have no idea why it won't work that way, not even sure what could cause it to not post.
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 08:58 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.04668 seconds
  • Memory Usage 2,396KB
  • 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
  • (4)bbcode_html
  • (9)bbcode_php
  • (7)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
  • (3)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
  • (5)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