View Full Version : Coding issue...
Saviour
06-08-2009, 11:42 AM
I have a dropdown call template and below is the code in the template:
<!-- post specs_menu -->
<if condition="$post['field23']">
<div style="background-image: url('http://glitchpc.com/forums/images/buttons/specs.gif'); position:absolute; width:auto;" id="specs_$post[postid]" class="vbmenu_control">
<a href="#specs">$vbphrase[dropdown_title]</a>
<script type="text/javascript"> vbmenu_register("specs_$post[postid]"); </script>
</div>
</if>
<!-- / post specs_menu -->
I want to exclude certain forums from using this code (or calling the template)...so I tried the following and I get a parse error...malformed conditional.
<!-- post specs_menu -->
<if condition="$forum[forumid] != XX">
<if condition="$post['field23']">
<div style="background-image: url('http://glitchpc.com/forums/images/buttons/specs.gif'); position:absolute; width:auto;" id="specs_$post[postid]" class="vbmenu_control">
<a href="#specs">$vbphrase[dropdown_title]</a>
<script type="text/javascript"> vbmenu_register("specs_$post[postid]"); </script>
</div>
</if>
</if>
<!-- / post specs_menu -->
The code above will work with one forum...where the forum ID is "XX". However, if I add another forum ID after the XX (separated by a comma) the conditional fails...malformed syntax.
Can someone help me correct this?
Thank you.
If I understand you correctly, you shoul write something like that.
<if condition="$forum[forumid] != XX || $forum[forumid] != YY">
Saviour
06-08-2009, 01:48 PM
Choo...thanks for the reply...
Nope...that didn't work, either...
But it should work :). Show your code. But that's not really proper variant. Try this.
$ids = array(123, 234, 345); //forums ids
<if condition="!in_array($forum[forumid], $ids)">
toonysnn
06-08-2009, 02:07 PM
Choo, you have the right idea, but the $ids must be in a php script, or if you have a setting group in vBulletin Options, you could do $vboptions['setting_name'] for the $ids replacement.
Lynne
06-08-2009, 02:39 PM
This should work for an array of forumids:
<if condition="in_array($forum['forumid'], array(xx,yy,zz))">
whatever
</if>
Saviour
06-08-2009, 02:58 PM
Okay...here's what I'm using...and I'm getting a parse error...
<!-- post specs_menu -->
$ids = array(8, 56, 58, 59, 60, 61, 62, 63, 64, 65, 66); //forums ids
<if condition="!in_array($forum[forumid], $ids)">
<if condition="$post['field23']">
<div style="background-image: url('http://glitchpc.com/forums/images/buttons/specs.gif'); position:absolute; width:auto;" id="specs_$post[postid]" class="vbmenu_control">
<a href="#specs">$vbphrase[dropdown_title]</a>
<script type="text/javascript"> vbmenu_register("specs_$post[postid]"); </script>
</div>
</if>
</if>
<!-- / post specs_menu -->
Thanks for the help, everyone...
Hi, Lynne...
--------------- Added 1244477096 at 1244477096 ---------------
Tried this, as well...still no workie...heh:
<!-- post specs_menu -->
<if condition="in_array($forum['forumid'], array(8,56,58,59,60,61,62,63,64,65,66))">
<if condition="$post['field23']">
<div style="background-image: url('http://glitchpc.com/forums/images/buttons/specs.gif'); position:absolute; width:auto;" id="specs_$post[postid]" class="vbmenu_control">
<a href="#specs">$vbphrase[dropdown_title]</a>
<script type="text/javascript"> vbmenu_register("specs_$post[postid]"); </script>
</div>
</if>
</if>
<!-- / post specs_menu -->
Lynne
06-08-2009, 04:17 PM
Try combining the two ifs, like suggest above. It also helps to know the exact error you are getting or if it's not working, exactly what you see is not working.
Saviour
06-08-2009, 04:29 PM
Don't take it for granted that because I have the word "Coder" under my username that I have a clue as to what you mean by combining the IF statements...sorry.
In this particular case...I get a parse error...I don't have the exact code...but it does refer to it being a conditional error. So...I'm assuming it has something to do with the way it's coded.
Lynne
06-08-2009, 04:40 PM
To combine two conditions, you just add an AND (or sometimes an OR, it depends on what you want) between the two. Remove the extra </if> after you combine them.
<if condition="in_array($forum['forumid'], array(8,56,58,59,60,61,62,63,64,65,66)) AND $post['field23']">
Saviour
06-08-2009, 04:44 PM
Used this code...and it does exactly what I want it to...which was to prevent the dropdown from appearing in the postbit.
Finally got it to work by using this code:
<!-- post specs_menu -->
<if condition="$forum[forumid] != 8">
<if condition="$forum[forumid] != 56">
<if condition="$forum[forumid] != 58">
<if condition="$forum[forumid] != 59">
<if condition="$forum[forumid] != 60">
<if condition="$forum[forumid] != 61">
<if condition="$forum[forumid] != 62">
<if condition="$forum[forumid] != 63">
<if condition="$forum[forumid] != 64">
<if condition="$forum[forumid] != 65">
<if condition="$forum[forumid] != 66">
<if condition="$post['field23']">
<div style="background-image: url('http://glitchpc.com/forums/images/buttons/specs.gif'); position:absolute; width:auto;" id="specs_$post[postid]" class="vbmenu_control">
<a href="#specs">$vbphrase[dropdown_title]</a>
<script type="text/javascript"> vbmenu_register("specs_$post[postid]"); </script>
</div>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
<!-- / post specs_menu -->
May be sloppy...but it works...
May look sloppy...but, hey...it works.
Thanks for all the help...
--------------- Added 1244510046 at 1244510046 ---------------
Lynne...
decided to use your code with the following exception:
<if condition="!in_array($forum['forumid'], array(8,56,58,59,60,61,62,63,64,65,66))">
</if>
Note exclamation point...
Thanks for the help...
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.