PDA

View Full Version : Removing vBMenu arrow?


BigJohnny
10-17-2010, 02:48 PM
How do you remove the arrow beside a popup menu? I have some code that uses the vBmenu class which adds that little down pointing arrow. I need to use the functionality, but since it will be activate over an image I can't have that little arrow show up, but only want to remove it for this one button image.

Lynne
10-17-2010, 05:06 PM
I believe the arrow gets added when you use vbmenu_register with your code. (I think... iirc.)

BigJohnny
10-18-2010, 12:54 AM
but do I not need to use that for the menu to work properly?

Heres the code chunk. When you use it, it makes the button but adds an arrow beside it.


<!-- NEW EVENT BUTTON DROP DOWN -->
<table cellpadding="0" cellspacing="0" border="0" style="margin-top:3px">
<tr valign="top">
<td id="add_event"><a href="#goto_newevent" rel="nofollow"><img src="$stylevar[imgdir_button]/newevent.gif" alt="$vbphrase[add_new_event]" border="0" /></a><script type="text/javascript"> vbmenu_register("add_event"); </script></td>

</tr>
</table>

<!-- add event menu -->
<div class="vbmenu_popup" id="add_event_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead">$vbphrase[add_new_event]</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="$vbphrase[single_all_day_event]" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=single&amp;c=$calendarinfo[calendarid]">$vbphrase[single_all_day_event]</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="$vbphrase[ranged_event]" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;c=$calendarinfo[calendarid]">$vbphrase[ranged_event]</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="$vbphrase[recurring_event]" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=recur&amp;c=$calendarinfo[calendarid]">$vbphrase[recurring_event]</a>
</td>
</tr>
</table>
</div>
<!-- / NEW EVENT BUTTON DROP DOWN -->

Lynne
10-18-2010, 04:10 AM
You know, a real quick search gives this - https://vborg.vbsupport.ru/showthread.php?t=202383

BigJohnny
10-18-2010, 10:58 AM
thanks lynne.... I don't know how I missed it, but I also had no idea that adding ",true" would remove the friggin arrow.

Working awesome now thanks.

My next question is going to be about regex and how to preg_replace this chunk of code where I need it. I can't seem to get a grasp on that.

I have code already to determine if the code should be inserted or not, I just need to be able to replace a chunk.

Lynne
10-18-2010, 01:38 PM
I'm not sure exactly what your question is or what you are trying to do next.

BigJohnny
10-18-2010, 07:09 PM
sorry, I was in a hurry this morning when writing that.

I'm using the vBEvents mod, and I have an events forum.

This button we just got working will show on forumdisplay. It will replace "new thread" with "new event" but ONLY in event forums.

Since I don't want to do this with a template conditional, or hardcoded forumid's vBEvents already has a plugin to determine if the forum is an event forum or not.

By default the mod hardcodes an event type option in the ACP so that when a user presses new thread in an event forum, they are redirected to a new event posting with one of the 3 types (single, recurring, ranged). The type is set in the mod options (1,2,3) and can only have one choice.

This button will replace that so in event forums it will be this nice little event type selector drop down box.

What I need to do is use preg_replace to find 2 chunks of code in FORUMDISPLAY and replace them with my own 2 chunks of code respectively.

I have no idea how to use preg_replace or regex, but I already have a plugin to put the code in.

Lynne
10-18-2010, 07:33 PM
I usually use str_replace when I modify template code using that method. Sometimes it is easier to just modify the template though. Exactly what are you trying to find and then replace?

BigJohnny
10-18-2010, 09:19 PM
oh, maybe str_replace would work too.

I only have half of this sorted at the moment.

I want to replace this

<!-- controls above thread list -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom:3px">
<tr valign="bottom">
<td class="smallfont"><if condition="$show['newthreadlink']"><a href="newthread.php?$session[sessionurl]do=newthread&amp;f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a><else />&nbsp;</if></td>
<if condition="$pagenav"><td align="$stylevar[right]">$pagenav</td></if>
</tr>
</table>
<!-- / controls above thread list -->


With this


<!-- controls above thread list -->
<!-- NEW EVENT BUTTON DROP DOWN -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom:3px">
<tr valign="bottom">
<td id="add_event" width="6%">
<if condition="$show['newthreadlink']"><a href="#goto_newevent" rel="nofollow"><img src="$stylevar[imgdir_button]/newevent.gif" alt="$vbphrase[add_new_event]" border="0" /></a><script type="text/javascript"> vbmenu_register("add_event", true); </script>
<else />&nbsp;
</if>
</td>

<if condition="$pagenav"><td align="$stylevar[right]" width="94%">$pagenav</td></if>
</tr>
</table>

<!-- Add Event Menu -->
<div class="vbmenu_popup" id="add_event_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead">Add New Event</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Single, All Day Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=single&amp;c=$calendarinfo[calendarid]">Single, All Day Event</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Ranged Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;c=$calendarinfo[calendarid]">Ranged Event</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Recurring Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=recur&amp;c=$calendarinfo[calendarid]">Recurring Event</a>
</td>
</tr>
</table>
</div>
<!-- / Add Event Menu -->
<!-- / NEW EVENT BUTTON DROP DOWN -->
<!-- / controls above thread list -->


Then I need to replace this


<!-- controls below thread list -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top:3px">
<tr valign="top">
<td class="smallfont"><if condition="$show['newthreadlink']"><a href="newthread.php?$session[sessionurl]do=newthread&amp;f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a><else />&nbsp;</if></td>

<if condition="$show['pagenav'] OR $show['inlinemod']">
<td align="$stylevar[right]">$pagenav
<if condition="$show['inlinemod']">
<div class="smallfont" style="text-align:$stylevar[left]; white-space:nowrap; float:$stylevar[right]">
<if condition="$show['pagenav']"><br /></if><strong>$vbphrase[moderation]</strong><br />
<select name="do">
<if condition="$show['deletethread'] OR $show['spamctrls'] OR $show['openthread'] OR $show['approvethread'] OR $show['movethread'] OR $template_hook['inlinemod_thread_bottom']">
<optgroup label="$vbphrase[option]">
<if condition="$show['deletethread']">
<option value="deletethread">$vbphrase[delete_threads]</option>
<option value="undeletethread">$vbphrase[undelete_threads]</option>
</if>
<if condition="$show['spamctrls']">
<option value="spamthread">$vbphrase[delete_threads_as_spam]</option>
</if>
<if condition="$show['openthread']">
<option value="open">$vbphrase[open_threads]</option>
<option value="close">$vbphrase[close_threads]</option>
</if>
<if condition="$show['approvethread']">
<option value="approvethread">$vbphrase[approve_threads]</option>
<option value="unapprovethread">$vbphrase[unapprove_threads]</option>
</if>
<if condition="$show['movethread']">
<option value="stick">$vbphrase[stick_threads]</option>
<option value="unstick">$vbphrase[unstick_threads]</option>
<option value="movethread">$vbphrase[move_threads]</option>
<option value="mergethread">$vbphrase[merge_threads]</option>
</if>
$template_hook[inlinemod_thread_bottom]
</optgroup>
</if>
<optgroup label="____________________">
<option value="viewthread">$vbphrase[view_selected_threads]</option>
<option value="clearthread">$vbphrase[clear_thread_list]</option>
</optgroup>
</select><input type="submit" class="button" id="inlinego" value="$vbphrase[go]" />
</div>
<script type="text/javascript">
<!--
inlineMod = new vB_Inline_Mod('inlineMod', 'thread', 'inlinemodform', '$vbphrase[go_x]');
//-->
</script>
</if>
</td>
</if>
</tr>
</table>
<!-- / controls below thread list -->


With this, Except this doesn't quite work. The menu doesn't open in the correct spot if you can see the inline moderation options.


<!-- controls below thread list -->
<!-- NEW EVENT BUTTON DROP DOWN -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top:3px">
<tr valign="top">
<td id="add_event" width="6%">
<if condition="$show['newthreadlink']"><a href="#goto_newevent" rel="nofollow"><img src="$stylevar[imgdir_button]/newevent.gif" alt="$vbphrase[add_new_event]" border="0" /></a><script type="text/javascript"> vbmenu_register("add_event", true); </script>
<!-- Add Event Menu -->
<div class="vbmenu_popup" id="add_event_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead">Add New Event</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Single, All Day Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=single&amp;c=$calendarinfo[calendarid]">Single, All Day Event</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Ranged Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;c=$calendarinfo[calendarid]">Ranged Event</a>
</td>
</tr>
<tr>
<td class="vbmenu_option">
<img class="inlineimg" src="$stylevar[imgdir_misc]/calendar_icon.gif" alt="Recurring Event" border="0" />
<a href="calendar.php?$session[sessionurl]do=add&amp;type=recur&amp;c=$calendarinfo[calendarid]">Recurring Event</a>
</td>
</tr>
</table>
</div>
<!-- / Add Event Menu -->
<else />&nbsp;
</if>
</td>

<if condition="$show['pagenav'] OR $show['inlinemod']">
<td align="$stylevar[right]">$pagenav
<if condition="$show['inlinemod']">
<div class="smallfont" style="text-align:$stylevar[left]; white-space:nowrap; float:$stylevar[right]">
<if condition="$show['pagenav']"><br /></if><strong>$vbphrase[moderation]</strong><br />
<select name="do">
<if condition="$show['deletethread'] OR $show['spamctrls'] OR $show['openthread'] OR $show['approvethread'] OR $show['movethread'] OR $template_hook['inlinemod_thread_bottom']">
<optgroup label="$vbphrase[option]">
<if condition="$show['deletethread']">
<option value="deletethread">$vbphrase[delete_threads]</option>
<option value="undeletethread">$vbphrase[undelete_threads]</option>
</if>
<if condition="$show['spamctrls']">
<option value="spamthread">$vbphrase[delete_threads_as_spam]</option>
</if>
<if condition="$show['openthread']">
<option value="open">$vbphrase[open_threads]</option>
<option value="close">$vbphrase[close_threads]</option>
</if>
<if condition="$show['approvethread']">
<option value="approvethread">$vbphrase[approve_threads]</option>
<option value="unapprovethread">$vbphrase[unapprove_threads]</option>
</if>
<if condition="$show['movethread']">
<option value="stick">$vbphrase[stick_threads]</option>
<option value="unstick">$vbphrase[unstick_threads]</option>
<option value="movethread">$vbphrase[move_threads]</option>
<option value="mergethread">$vbphrase[merge_threads]</option>
</if>
$template_hook[inlinemod_thread_bottom]
</optgroup>
</if>
<optgroup label="____________________">
<option value="viewthread">$vbphrase[view_selected_threads]</option>
<option value="clearthread">$vbphrase[clear_thread_list]</option>
</optgroup>
</select><input type="submit" class="button" id="inlinego" value="$vbphrase[go]" />
</div>
<script type="text/javascript">
<!--
inlineMod = new vB_Inline_Mod('inlineMod', 'thread', 'inlinemodform', '$vbphrase[go_x]');
//-->
</script>
</if>
</td>
</if>
</tr>
</table>
<!-- / NEW EVENT BUTTON DROP DOWN -->
<!-- / controls below thread list -->


Then I need to make some changes to showthread to either modify the "new thread" button in the same way or I need to remove the code for the "new thread" button which is probably what I will do.

The complications come into play because these buttons only need to be modified for certain forums, which are subject to change, so I need to be able to have it done through plugins to avoid having to modify a ton of templates if I want to add a new event forum or remove one etc.

Lynne
10-18-2010, 10:36 PM
I would just do a template edit. That is way too much - along with a bunch of conditions - to be wanting to do a str_replace with.

BigJohnny
10-19-2010, 12:25 AM
the reason for that is because the mod doesn't actually change the template. So if I use template conditions, then I need to use hardcoded forumid's to determine where the button would show.

This means that if I add other event forums, I will have to edit the template each time a forum is added or removed. It may not happen often, but it would be easier if it would happen automatically. plus I have like 6 styles which would need the same changes.