The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How to phrase part of a conditional statement?
I have a conditional statement that I'm using in multiple templates numerous times.
It contains an array of forum ids that I want to display differently than the standard forums. Everything works well using this conditional: Code:
<vb:if condition="!in_array($GLOBALS['forumid'], array(23, 24, 25, 26, 27, 28, 49, 77))"> The probem I want to avoid is if I want to add another forum to this list, as of now I will have to go back, find, and then edit every single conditional individually. I've tried to phrase the array like this: Code:
<vb:if condition="!in_array($GLOBALS['forumid'], array({vb:rawphase special_forums))"> But that just gives this error: Quote:
Anyone have a solution? |
#2
|
|||
|
|||
If you're setting an array called $special_forums in a plugin, like maybe:
Code:
global $special_forums; $special_forums = array(23, 24, 25, 26, 27, 28, 49, 77); then you can do this: Code:
<vb:if condition="!in_array($GLOBALS['forumid'], $GLOBALS['special_forums'])"> It looks like you were trying to us a phrase to list the forums? That won't work because the part inside the condition is php code, and it won't parse the template tags. |
#3
|
||||
|
||||
So, if I needed the plugin to be available for multiple templates - postbit, SHOWTHREAD, newthread.
Will I need multiple plugins? |
#4
|
|||
|
|||
No, you just need to use a hook that's executed for every page, like one of the global_* hooks (Edit: or parse_templates. That's probably a good one since it's called once before any templates are used).
|
#5
|
||||
|
||||
I still getting an error with the conditional statement you posted above:
Quote:
Code:
<vb:if condition="!in_array $GLOBALS['forumid'], $GLOBALS['special_forums']"> Code:
<vb:if condition="!in_array ($GLOBALS['forumid'], $GLOBALS['special_forums'])"> |
#6
|
|||
|
|||
I did leave out a closing paren, which I just went back and inserted. But it looks like the second one you posted above should work (of course you need the closing </vb:if> somewhere as well).
What is the error you're getting? If it's an error when you try to save the template you might want to try taking out the if and see if you still get the error. |
#7
|
||||
|
||||
The error when I try to save is this:
Quote:
If I remove the "if" the error is this: Quote:
|
#8
|
|||
|
|||
OK, I just tried this and it works (at least as far as being valid template syntax):
Code:
<vb:if condition="!in_array ($GLOBALS['forumid'], $GLOBALS['special_forums'])"> Stuff here </vb:if> So it's possible that you have something else wrong in the template. The second error does say something about "invalid tag nesting", so if you took out only the <vb:if ...> tag but not the corresponding </vb:if> then that might be why. |
#9
|
||||
|
||||
Alright I'll see if I can't figure out why it still won't work on my end.
I forgot to post that the error is referenced at: Quote:
Code:
function fetch_error_array($errors) { $compiled_errors = array(); foreach ($errors as $key => $value) { if (is_string($value)) { $compiled_errors[$key] = fetch_error($value); } else if (is_array($value)) { $compiled_errors[$key] = call_user_func_array('fetch_error', $value); } } return $compiled_errors; } |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|