PDA

View Full Version : WYSIWYG editor


Mythotical
20 Nov 2009, 20:32
Has anyone figured out how to add the editor to 4.0 custom scripts? I am trying to figure out but why try to reinvent the wheel if someone already figured it out.

Thanks
Steve

micheal332001
23 Nov 2009, 11:04
i would like to know this as well.

I have it working on my scripts but its layout is all wrong.

xman_79
23 Nov 2009, 14:25
the template :



<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" />

<form class="vbform block" action="file.php" method="post" name="vbform" onsubmit="return vB_Editor['{vb:raw editorid}'].prepare_submit(this.inputname.value, {vb:raw vboptions.postminchars})">

<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 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="mydo" />
<input type="submit" class="button" name="sbutton" id="{vb:raw editorid}_save" value="{vb:rawphrase myphrase}" accesskey="s" tabindex="2" />
</div>
</div>

</form>



the php file



require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar('',1,'signature',1,1,($vbulletin->userinfo['userid']));

In your $templater->register , add

$templater->register('editorid', $editorid);
$templater->register('messagearea', $messagearea);

Mythotical
23 Nov 2009, 14:43
Well thank you xman_79. That will help quite a bit.

You can submit the article or I can submit an article, your call xman_79.

xman_79
23 Nov 2009, 15:02
Welcome ..

My problem is : I don't speack english :( ...

Mythotical
23 Nov 2009, 15:11
Welcome ..

My problem is : I don't speack english :( ...

No worries, I will put the article up then. I'm gonna test the code to make sure it works and test various ways but over all I'm confident it works.

micheal332001
23 Nov 2009, 19:04
the template :



<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" />

<form class="vbform block" action="file.php" method="post" name="vbform" onsubmit="return vB_Editor['{vb:raw editorid}'].prepare_submit(this.inputname.value, {vb:raw vboptions.postminchars})">

<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 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="mydo" />
<input type="submit" class="button" name="sbutton" id="{vb:raw editorid}_save" value="{vb:rawphrase myphrase}" accesskey="s" tabindex="2" />
</div>
</div>

</form>

the php file



require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar('',1,'signature',1,1,($vbulletin->userinfo['userid']));

In your $templater->register , add

$templater->register('editorid', $editorid);
$templater->register('messagearea', $messagearea);



Thankyou very much that worked great.

xman_79
23 Nov 2009, 20:55
Well thank you xman_79. That will help quite a bit.

You can submit the article or I can submit an article, your call xman_79.

No worries, I will put the article up then. I'm gonna test the code to make sure it works and test various ways but over all I'm confident it works.

If you want to publish this article you can also publish my article "How can I use the quick editor" published in the French-language in vbulletin-ressources.com .

My name is Suleiman .

http://www.vbulletin-ressources.com/forum/showthread.php?t=17708

Mythotical
24 Nov 2009, 03:29
Done and done, thanks, I went off of your article on that site to finish up mine.

Lionel
24 Nov 2009, 22:00
abDoes anyone know how to activate the new attachment option in the code above?

I see this in newthread

require_once(DIR . '/packages/vbattach/attach.php');
$values = "values[f]=$foruminfo[forumid]";
$attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post');
$attachmentoption = $attach->fetch_edit_attachments($posthash,

$poststarttime, $postattach, 0, $values, $editorid, $attachcount);
$contenttypeid = $attach->fetch_contenttypeid();
require_once(DIR . '/includes/functions_file.php');
$attachinfo = array(
'auth_type' => (empty($_SERVER['AUTH_USER']) AND empty($_SERVER

['REMOTE_USER'])) ? 0 : 1,
'posthash' => $posthash,
'poststarttime' => $poststarttime,
'userid' => $vbulletin->userinfo['userid'],
'contenttypeid' => $contenttypeid,
'max_file_size' => fetch_max_upload_size(),
'values' => array(
'f' => $foruminfo['forumid']
)and then

require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar('',1,'nonforum',1,1,($vbulletin->userinfo['userid']),'fe','',$attachinfo);