PDA

View Full Version : [How-To] Create your own Inline Moderation


Revan
07 Jul 2006, 12:01
This How-To will only work with the upcoming Beta 5 or RC1 or whatever they decide to name it. It will not work with Beta 4, because of this thread (http://www.vbulletin.com/forum/showthread.php?t=190808).

Wouldn't it be cool to have your own Inline Moderation? Of course it would. Especially if you paginate your results (http://www.vbulletin.org/forum/showthread.php?t=120540), you might want to mark multiple items across pages.

You don't need to understand AJAX in order to find this guide useful. Hell I don't know much AJAX, I'm just good at tinkering with code until it works :p

Im assuming you know how to create and submit forms, so I won't go into details on how to alter the example form in order to make it work with your hack.

Make sure your php file has the "inlinemod" phrasetype included.

<form action="l2cp.php" method="post" id="banmanageform">
The one thing you should know about this form is that the l2cp.php or whatever you decide to put there, is the file that will handle your inline moderation. vBulletin uses inlinemod.php for this purpose.
In order to get the fancy dropdown menu, put this in the bit where you have the class="thead":
<if condition="$show['popups']">
<td class="vbmenu_control" id="imod" align="center" title="$vbphrase[moderation]"><script type="text/javascript"> vbmenu_register('imod'); </script></td>
<else />
<td class="tcat" align="center">
<input type="checkbox" name="allbox" id="checkall_all" title="$vbphrase[check_uncheck_all]" onclick="inlineMod.check_all()" />
</td>
</if>
Then a little later somewhere put this:
<if condition="$show['popups']">
<div class="vbmenu_popup" id="imod_menu" style="display:none" align="$stylevar[left]">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead">$vbphrase[l2cp_from_this_page]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all(true)">$vbphrase[select_all]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all(false)" id="arse">$vbphrase[deselect_all]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all('invert')">$vbphrase[invert_selection]</td></tr>

</table>
</div>
</if>
Put this wherever you want it to appear:
<strong>$vbphrase[moderation]</strong><br />
<select name="do">
<optgroup label="$vbphrase[option]">
<option value="someaction">$vbphrase[somephrase]</option>
</optgroup>
</select><input type="submit" class="button" id="inlinego" value="$vbphrase[go]" />
<input type="hidden" name="s" value="$session[sessionhash]" />
</div>
<script type="text/javascript" src="clientscript/vbulletin_inlinemod.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
inlineMod = new vB_Inline_Mod('inlineMod', 'post', 'banmanageform', '$vbphrase[go_x]', 'productname_inline');
//-->
</script>This has a ton of things to explain.
First of all, the select is what determines what action the script should do.
Secondly, theres the new vB_Inline_Mod(). That's used to instantiate the JS class. The first parameter is the varname, in this case inlineMod. Next you'll have whether or not this is a thread or a post, you have to leave it at post. Next is the form name like you defined above, then the vbphrase for the go (0) button, then the cookiename. You can make that anything you want, just make sure its unique.
The final bit here is the checkbox that'll mark the result bit, so in your repeating template put this:
<input type="checkbox" name="plist[$idvar]" id="plist_$idvar" style="vertical-align:middle; padding:0px; margin:0px 0px 0px 5px" />
The only thing you need to change here is the $idvar. That can be anything such as {$result[userid]} or whatever.


That should do the trick :)
Feel free to ask if there's anything you find unclear, I was in sort of a hurry and Im not very good at explaining :(

Jaxel
24 Sep 2009, 19:28
I'm having trouble with this guide... these are my templates:

FORM:
<form action="videoajax.php" method="post" id="videoComments">

<a name="comments" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" width="100%">
$vbphrase[comments]
</td>
<if condition="$show['popups']">
<td class="vbmenu_control" id="imod" align="center" title="$vbphrase[moderation]"><script type="text/javascript"> vbmenu_register('imod'); </script></td>
<else />
<td class="tcat" align="center">
<input type="checkbox" name="allbox" id="checkall_all" title="$vbphrase[check_uncheck_all]" onclick="inlineMod.check_all()" />
</td>
</if>
</tr>
<tr valign="top">
<td class="alt1" colspan="2"><div id="vidCommentsAll">
<ol class="list_no_decoration alt1 block_row" id="message_list">$commentbits</ol>
</div></td>
</tr>
</table>

<div id="vidPageselAll">$pagenav</div>

<div align="right">
<strong>$vbphrase[moderation]</strong>
<select name="do">
<optgroup label="$vbphrase[option]">
<option value="deletecomments">Delete Comments</option>
</optgroup>
</select>
<input type="submit" class="button" id="inlinego" value="$vbphrase[go]" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<script type="text/javascript" src="clientscript/vbulletin_inlinemod.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
inlineMod = new vB_Inline_Mod('inlineMod', 'post', 'videoComments', '$vbphrase[go_x]', 'videocomments_inline');
//-->
</script>
</div>

<if condition="$show['popups']">
<div class="vbmenu_popup" id="imod_menu" style="display:none" align="$stylevar[left]">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead">$vbphrase[moderation]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all(true)">$vbphrase[select_all]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all(false)" id="arse">$vbphrase[deselect_all]</td></tr>
<tr><td class="vbmenu_option" onclick="inlineMod.check_all('invert')">$vbphrase[invert_selection]</td></tr>
</table>
</div>
</if>

<script type="text/javascript" src="clientscript/vbulletin_ajax_videocomment.js"></script>

</form>

BIT:
<li id="vcomment$comment[videocommentid]" class="floatcontainer">
<if condition="$comment['avatarurl']">
<div class="fixed_width_avatar">
<if condition="$comment['postuserid']"><a href="member.php?$session[sessionurl]u=$comment[postuserid]"></if><img src="$comment[avatarurl]" class="alt2 avatar"<if condition="$comment['avatarwidth']"> width="$comment[avatarwidth]"</if><if condition="$comment['avatarheight']"> height="$comment[avatarheight]"</if> border="0" alt="$comment[username]" /><if condition="$comment['postuserid']"></a></if>
</div>
<div class="visitor_message_avatar_margin">
</if>
<div class="tborder info_bar">
<div class="alt2 smallfont">
<if condition="$show['deletionlink']"><input type="checkbox" class="inlinemod_checkbox" name="clist[$comment[videocommentid]]" id="clist_$comment[videocommentid]" /></if>
<div class="visitor_message_date"><a href="$video[url]">$video[title]</a> @ $comment[date], <span class="time">$comment[time]</span></div>
<if condition="$comment['postuserid']">
<a href="member.php?$session[sessionurl]u=$comment[postuserid]">$comment[musername]</a>
<else />
<phrase 1="$comment[musername]">$vbphrase[guest_x]</phrase>
</if>
</div>
</div>

<div id="vcomment_text_$comment[videocommentid]" class="visitor_message_body">
$comment[message]
</div>

<ul class="list_no_decoration controls">
<if condition="$show['deletionlink']">
<li class="smallfont"><a href="video.php?$session[sessionurl]do=deletecomment&amp;commentid=$comment[videocommentid]">$vbphrase[delete_video_comment]</a></li>
</if>
</ul>
<if condition="$comment['avatarurl']">
</div>
</if>
</li>

Two problems...

1 - class="floatcontainer" should change to class="floatcontainer inlinemod" when a bit is checked... it doesn't here...

2 - selections are not saved on page-switch; or added to the "Go (0)" count on the submit form.

Please take a look at my code and tell me what I am missing.

Jaxel
28 Sep 2009, 20:53
Found another issue... the drop-down menu doesn't work. If I hit "select all", it doesn't select anything.

--------------- Added 1254172453 at 1254172453 ---------------

Figured It Out!

<script type="text/javascript">
<!--
inlineMod = new vB_Inline_Mod('inlineMod', 'post', 'banmanageform', '$vbphrase[go_x]', 'productname_inline');
//-->
</script>

I changed 'post' to 'vmessage' and now it works!

--------------- Added 1254173076 at 1254173076 ---------------

Wait... actually, there is still an error...

Selections are not saved on page-switch; or added to the "GO" count"