vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Coding issue... (https://vborg.vbsupport.ru/showthread.php?t=215649)

Saviour 06-08-2009 11:42 AM

Coding issue...
 
I have a dropdown call template and below is the code in the template:

Code:

<!-- 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.

Code:

<!-- 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.

Choo 06-08-2009 01:15 PM

If I understand you correctly, you shoul write something like that.
Code:

<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...

Choo 06-08-2009 02:04 PM

But it should work :). Show your code. But that's not really proper variant. Try this.
Code:

$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:
HTML Code:

<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...

Code:

<!-- 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 [DATE]1244477096[/DATE] at [TIME]1244477096[/TIME] ---------------

Tried this, as well...still no workie...heh:

Code:

<!-- 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.
HTML Code:

<if condition="in_array($forum['forumid'], array(8,56,58,59,60,61,62,63,64,65,66)) AND $post['field23']">


All times are GMT. The time now is 03:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01092 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (2)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete