The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Use array from plugin in template as conditional
Hey Guys,
I have read a lot about using variables from plugins inside the FORUMDISPLAY template. But nothing really covers what I'm trying to do. What I'm trying to do is create a conditional based on specific parent forumids - but using an array. I can access the parentlist id's on a page using Code:
{vb:raw $foruminfo[parentlist]} Once I have that, I want to basically say, if 'parentlist' CONTAINS '610' then show this. I know you can't do a CONTAINS conditional that way because vbulletin doesn't allow it, and the parenlist is just a string, not an array. So I need to make a plugin to turn the parentlist into and array. Then register it for use in the FORUMDISPLAY template. For that I used PHP Code:
Now I want to say in my FORUMDISPLAY template. If $parentarray CONTAINS '610' then show this. For which is used: Code:
<vb:if condition="in_array(610, parentarray)"><!-- It's working --></vb:if> I believe everything is working up to the conditional statement, and I'm not sure if I'm accessing the parentarray variable in the right way. Any help would be appreciated. Thanks, hilaryl |
#2
|
|||
|
|||
Quick look without reading... ( I will do that later... dinner is calling )
Code:
<vb:if condition="in_array(610, $parentarray)"></vb:if> |
#3
|
|||
|
|||
Quote:
As well as the addition of the '$' before the variable. Thanks for your quick reply! Cheers |
#4
|
|||
|
|||
Yep, I typed it quickly and the last paren should be removed. Sorry about that. I corrected the post above. Keep the '$'.
I was holding up dinner, and I was suppose to be grilling the steaks. Are you testing on a live hosted board or a local test board? If you are on a local test board add conditionally some diagnostic functions to the safe_functions array. Even "var_dump" can be useful to see if you passed the correct data and type. |
#5
|
|||
|
|||
Quote:
We are on a live server, so my changes are live. Upon adding the '$', I still get an error message when I 'Save and Reload'. Code:
Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3555 The following error occurred when attempting to evaluate this template: %1$s This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. I would prefer it if what I was doing was legit in terms of vBulletin validation. Cheers |
#6
|
|||
|
|||
I am now looking into this. I am reproducing your results. It was not doing this on my main system. but then I run a different lexical/parser setup. When I checked it against (vb 4.2.2, vb 4.2.1) -- I received the same error.
This problem might have been around a while. As this sure seems similar. https://vborg.vbsupport.ru/showthread.php?t=109915 |
#7
|
|||
|
|||
We are running vBulletin 4.1.9 Patch Level 4
Cheers |
#8
|
|||
|
|||
Still testing...
|
#9
|
|||
|
|||
Thanks tbworld! I really appreciate your help with this.
I've had a read of the link you gave above. It appears to be exactly the same problem, however it doesn't appear to be solved. I don't think the in_array() is the issue, because the FORUMDISPLAY template was able to validate the following, and it works as a conditionally statement too. Code:
<vb:if condition="in_array(610, array(610,690,-1))"><!-- It's Working --></vb:if> Cheers |
#10
|
|||
|
|||
In line (78) of template search_common.
Code:
<vb:if condition="in_array($type, $selectedtypes)"> checked="checked"</vb:if> vb4.2.2 it fails. Does the conditional work correctly, if you force the saving of the template? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|