![]() |
Forum if condition not working
Not sure what is going on but my if condition is not working. Not sure why but it is getting annoying.
$foruminfo['forumid'] works for showing when you click on the category itself but not when your viewing threads inside a forum. HTML Code:
<if condition="in_array($forum['forumid'], array($vboptions['pl9_qloc']))"> Any help much appreciated. Thanks Steve --------------- Added [DATE]1262664726[/DATE] at [TIME]1262664726[/TIME] --------------- Well a response was here, got an email so here is my reply. As I didn't give the template I'm trying to use this in, I have added this: Code:
navbar Thanks |
If you look in the includes/functions.php file where the navbar is rendered, you'll see that $forum is not registered for use in that template. However, $foruminfo is registered for use, so try using that variable instead.
|
Yeah I have it in the conditional already, let me post the full conditional.
HTML Code:
<if condition="in_array($foruminfo['forumid'], array($vboptions['pl9_qloc'])) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], array($vboptions['pl9_qloc']))"> Category view with forums Now click into one of those forums and it goes away. EDIT: $vboptions[pl9_qloc] has all forums selected so all forum id's are in the settings row. |
Oh yikes, and I'm mixed up between vb4 and vb3, sorry about the stuff regarding registering!
You said that what I'm looking for is in the navbar, but I don't see anything different in the navbar when I click on one of the forums from the page you link to. What should I be looking for exactly? Another thing..... when I've had a option field where I input a row of forumids... x,y,z and then I wanted to use them like you are (if in_array etc...), I've had to first explode it in a plugin... ie. I have some forums set in option "verify_forums" (ie. 12,13,14) In my plugin, I have PHP Code:
HTML Code:
in_array($threadinfo[forumid], $verifyforums) |
Oh yeah sorry, the quote box goes away. Its above the navbar but I forgot to allow guests to see it. Let me change that, just keep refreshing on that first link and you will see it appear.
Good point on the explode, I will give that a try. --------------- Added [DATE]1262668603[/DATE] at [TIME]1262668603[/TIME] --------------- Ok you as a guest can now see the quote box. I'm such an idiot for not remembering to give perms to guests. --------------- Added [DATE]1262668880[/DATE] at [TIME]1262668880[/TIME] --------------- Ok did the explode function and changed the $foruminfo to reflect $pl9_qloc in the array but with $foruminfo['forumid'] it didn't show on any forum page. |
I see it now. It seems the only forumid it is currently working in is forumid 1. I would try the explode thing cuz I'm pretty sure that is it. The text field is simply a string as an option, so you need to turn it into an array before you can do your in_array condition.
|
Did the explode, here is what I have in the global_start plugin:
PHP Code:
|
And your condition is now like this ?
HTML Code:
<if condition="in_array($foruminfo['forumid'], $pl9_quoteloc) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)"> Also, it looks like in your query, you are only pulling one row. You could just use query_first instead and then you don't have to do the fetch_array stuff: PHP Code:
|
Oh no, the forumid stuff has nothing to do with the quotes in the database, that is separate. Basically I am just trying to get the if condition to work so it will display the quote box on the forumdisplay page that I choose.
I just changed my if condition to what you suggested as I still had: HTML Code:
<if condition="in_array($foruminfo['forumid'], array($pl9_quoteloc)) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)"> The following error occurred when attempting to evaluate this template: Code:
Warning: in_array() [function.in-array]: Wrong datatype for second argument in [path]/includes/adminfunctions_template.php(3950) : eval()'d code on line 1 |
OK, this is odd because it really is almost exactly the type of condition I use in a mod of mine. (Sorry I took off, sleep was calling.)
Check your options for pl9_qloc - is the data validation type set to Free ? This is exactly my code in my plugin: PHP Code:
HTML Code:
<if condition="is_member_of($vbulletin->userinfo,array(5,6)) AND in_array($threadinfo['forumid'], $verifyforums)"> PHP Code:
HTML Code:
<if condition="in_array($foruminfo['forumid'], $pl9_quoteloc) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)"> PHP Code:
|
No worries, sleep was calling me too.
I am missing something here, I know I am. I just can't put my finger on it. Maybe I should move the if condition to the plugin instead. I am searching all forums dealing with vB coding for that warning and I'm still reading threads. |
I am stumped. I mean, our code looks almost identical and yet mine works and I do not get that error. Try really shortening it just to see what happens...
HTML Code:
<if condition="in_array($foruminfo['forumid'], $pl9_quoteloc)"> |
Interesting, if I spit out $pl9_quoteloc it returns:
Code:
Array Code:
1,2,3,31,4,5,6,7,8,9,23,10,24,11,25,12,26,13,27,14,15,28,16,29,17,30,18,19,20,21,22 |
And $pl9_quoteloc *should* return an array and it *should* work in that condition. Did you try just using the one simple condition? If you get the error, have you tried just telling it to use it anyway and seeing what happens? (And yes, I get the same results you do - Array for the first variable and the string of forumids if I print out the other.)
|
Yep I tried the one simple condition. I have saved it and told it to use it anyway and it still works so I don't see the problem.
I have discovered something though. If I change it to include array() like so: HTML Code:
in_array($foruminfo['forumid'], array($pl9_quoteloc)) |
But it doesn't work like that, right?
Try printing out $foruminfo['forumid'] also and see what prints out. Also, did you ever check the data type of the option and see if it is set to Free? |
Right, it stops working as soon as I add array()
I tried printing $foruminfo['forumid'] and it caused my if condition to stop working so I had to move that inside the if condition and it prints out the forum id properly. |
Quote:
Quote:
Seriously, please check that. I've said it a couple of times now. |
Oh sorry, I keep forgetting to mention that, yeah I checked it and it is set to Free.
Also I am using $foruminfo[forumid] without single quotes as well. The warning is referring to $pl9_quoteloc portion. --------------- Added [DATE]1262724383[/DATE] at [TIME]1262724383[/TIME] --------------- You know what, let me try this on my fresh vb test site. |
When I set the option to Numeric on my site, I get the exact problem you get - it only works for the first forumid. That's why I emphasized you needing to verify that datatype.
|
I might know the problem then. I tried to install on my fresh test site but same problem so you saying that might help then.
--------------- Added [DATE]1262725405[/DATE] at [TIME]1262725405[/TIME] --------------- EDIT: Fixed the database error. Seems when I went back and changed things then changed them again, it some how added multiple entries of the same setting to the database. So that is fixed but still I can't figure out why I keep getting that warning when saving the template. --------------- Added [DATE]1262729717[/DATE] at [TIME]1262729717[/TIME] --------------- I will just leave it as is for now and figure it out later. I need to get this released so I will make sure everyone knows about the warning but I doubt anyone will mess with that template. |
Once it's released, I can download it and try it out on my 3.8 test site and maybe I'll see something that we've missed.
|
Ok I will probably get it released tomorrow or Thursday. Got a few more features to finish up first.
|
All times are GMT. The time now is 03:55 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|