Quote:
Quote:
In general to do this for arrays it would be: Code:
<if condition="in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> Code:
<if condition="!in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> |
I'm trying to find the conditional to include "in every forum except (several forums). I wasn't sure what the "!=" meant but I thought that might be it so I tried this but it was a no-go.
Code:
<vb:if condition="!in_array($foruminfo[forumid], array(26, 46 )">MyScript</vb:if> I'm using vB4.... |
Quote:
(Also, this is a vB3 article, although most of the conditions are valid, but in vB4 it does matter what template you use a variable in.) |
I was using it in the same FORUM DISPLAY template that we changed that variable to fix. Sorry I posted in the vB3 article. I didn't realize it till after I had done it but then figured it was still my best chance because the post just before seemed to relate.
I tried posting in my other thread but it did that auto-merge again : ( (but I see you found it anyways...LOL.) |
The VB4 version of this thread is here. I don't want to talk about VB4 in a VB3 thread. If you're still having issues please post in the VB4 thread for help.
|
Yes, I apologize. I didn't realize it when I first typed my post... Then I left it.
Moving on... |
I want to exclude the forums listed below. But when I use this conditional, I get an error. What am I doing wrong? I'm running 3.8.6 PL1
Code:
<if condition="$forum[forumid] != 1,2,3,4">google ad code here</if> I get the error: Code:
The following error occurred when attempting to evaluate this template: I'd also like to exclude certain usergroups from seeing ads. How do I accomplish both of these things? |
What's wrong is your condition is wrong... it should look like this:
Code:
<if condition="!in_array($forum['forumid'], array(1,2,3,4))"></if> |
Thanks! Is there a way to use two conditionals? I don't want ads showing up in certain forums, and there's on particular usergroup that I want to block ads from. Is this possible?
|
Code:
<if condition="!in_array($forum['forumid'], array(1,2,3,4)) AND !is_member_of($vbulletin->userinfo, 5,6)"> |
I'm sorry to be a pain, but this is what I used and the ads are still showing up on every forum. I have one particular forum where sponsors answer questions. This forum as an "Ask the Expert" forum with several child forums dedicated to each individual expert. I don't want ads for competitors showing up there. What is wrong with my code now? I have included the "Ask the Expert" forum ID, along with the IDs for all the child forums. Ads cannot show up in these forums, and I don't want the "experts" usergroup to see any at ads at all...on any forum.
Code:
<center><if condition="!in_array($forum['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40)) AND !is_member_of($vbulletin->userinfo, 7,14)"><script type="text/javascript"><!-- |
Where are you putting this code?
Some places user different variables, instead of $forum['forumid'] try $thread['forumid'] or $foruminfo['forumdid'] or $threadinfo['forumid'] (if you're in a thread). |
I've tested it on ad_navbar_below.
--------------- Added [DATE]1296756776[/DATE] at [TIME]1296756776[/TIME] --------------- When I try the $foruminfo['forumdid'] code, the ad shows up as "page cannot be displayed". I'm gonna try the other two suggestions and see if they work. |
Quote:
|
None of these seem to work. I'm so frustrated b/c I've had a server load problem and have narrowed it down to the Adsense hack I have installed. I'm hoping to find a workaround for this by using these conditionals, but they don't want to cooperate with me. :(
--------------- Added [DATE]1296759302[/DATE] at [TIME]1296759302[/TIME] --------------- The problem is that even though it said "page cannot be displayed", it was still showing up in a forum that it shouldn't be in. I made a test user and put it in the "experts" usergroup, and could see all ads. --------------- Added [DATE]1296759410[/DATE] at [TIME]1296759410[/TIME] --------------- I'm just going to try to get it to not show up in the experts forum, and forget about blocking ads throughout the entire forum for my experts group. |
I just tested this on my forum, it's definitely $foruminfo['forumid'] to show the ad code in specific forums (forumdisplay) and threads in that forum (showthread.)
If you get the page can't be displayed message in the ad box you have an error in the code you copied from google to show the ad. The fact that the box shows means the conditional is working. |
I don't know what I'm doing wrong, but if you don't mind, can you please take a look at my code and see if anything looks wrong? I'm copying the code directly from Google. My hack works fine, but I disable it to test out the conditionals.
Code:
<if condition="!in_array($foruminfo['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40))"><script type="text/javascript"><!-- Also, could my PHP version be the problem? I'm running 5.2.16. --------------- Added [DATE]1296771156[/DATE] at [TIME]1296771156[/TIME] --------------- The answer is to use $GLOBALS instead of $foruminfo. Works like a charm! |
I copied your code into my forum and the condition works perfectly fine for me (in the ad_navbar_below template) which is shown in the navbar template...
What exactly isn't working? I can't test the google code obviously but it looks like it should work if you had numbers in place of the x's. DO you have a kink to a forum this is running on? |
Nope, no kinks. This code works:
Code:
<if condition="!in_array($GLOBALS['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40))"> AND <if condition="!is_member_of($vbulletin->userinfo, 1,2)"> Code:
<if condition="!is_member_of($bbuserinfo, 14)> --------------- Added [DATE]1296779481[/DATE] at [TIME]1296779481[/TIME] --------------- Oh, the problem was that the ads were showing up in the forums I didn't want them to show up in. They were also showing up to the usergroups I didn't want them showing up to. The "page cannot be displayed" was just a glitch with one of the image ads. That's all that was. |
i have problem in conditional coding too .
i am pasting this in one of my template ad location ad_showthread_firstpost <if condition="THIS_SCRIPT != 'adv_index' AND THIS_SCRIPT != 'register' AND $GLOBALS[forumid] != 6"> and getting this error Parse error: syntax error, unexpected ',' in /home/forum/public_html/includes/adminfunctions_template.php(3772) : eval()'d code on line 1 can anyone help ?. |
Can somebody tell me how to hide code tags with something else for unregistered users using if conditional statement?
|
You need to edit your bbcode templates, such as the template: bbcode_code
Put the entire template in a template conditional- something like: Code:
<if condition="$show[member]"> |
Quote:
|
I have an ad that I want to show to one particular social group. This is the code I tried but it didn't work:
if condition="$groups[groupid] == X if condition="$group[groupid] == X if condition="$grps[groupid] == X Are there any conditionals for social groups? |
Quote:
The only other possibility would be to try Code:
$vbulletin->GPC[groupid] Code:
<if condition="$vbulletin->GPC[groupid] == x"> |
I'm trying to use it in the ad location template ad_navbar_below. This didn't work either:
<if condition="$vbulletin->GPC[groupid] == x"> |
Yeah I looked through the code, this just isn't going to be possible with a template conditional. For who knows what reason the people who programmed social groups did not make them behave like forums and threads which would have been logical.
|
Thank you for trying to help.
|
I'm trying to make a conditional that will display in all forums except 8 forums,
Quote:
|
Quote:
HTML Code:
<if condition="$show['newthreadlink'] && !in_array($forum['forumid'], array(6,7,8,9,22,23,24,25))"> |
Thanks for the fix, but it doesnt work :( I changed the code to make testing have less variables
Quote:
|
Try this: (sometimes && doesn't doesn't play well in templates)
HTML Code:
<if condition="$show['newthreadlink'] AND $forum['forumid'] == 8"> |
Quote:
HTML Code:
<if condition="$show['newthreadlink'] AND $thread['forumid'] == 8"> |
Quote:
@TheLastSuperman, this is for VB3. |
If you search the template you are putting the custom code in, look at what variable names are already being used.
In showthread $forum is never used... Nor is $thread, the actual one used is $threadinfo. In forumdisplay it's $foruminfo.... So for the forumdisplay template this would be the code: PHP Code:
|
OMG THAT WORKED!
Thank you Thank you! THANK YOU! |
Quote:
Looked in the db, read some docs, and got it right on the first try. :) Code:
<if condition="$thread[postuserid] == 15"> Code added to the template could show a message to members/guests (unless further limited by more conditionals), in posts created by this specific thread starter. For example, to add a unique secondary signature by an admin in new threads. You can hard code the message, or add a new phrase variable. ### |
thanks.
|
Quote:
Code:
<if condition="in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> Code:
<if condition="!in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> |
Thanks. Updated original post. :up:
|
All times are GMT. The time now is 10:45 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|