View Full Version : Condition worked in 4.0.1, but not in 4.0.2
utahraves
02-22-2010, 07:56 PM
This was the same conditional IF command I was using on 4.0.1, upgraded and now it no longer works?
Template: Postbit
<vb:if condition="(THIS_SCRIPT == showthread) AND (($post[postcount] % 5) == 0)">
<div class="attachments" align=center>
...
</div>
</vb:if>
The code is to display a banner after every five posts only in SHOWTHREAD (postbit shows up as private messages too).
Even taking out the "THIS_SCRIPT == showthread) AND" did not resolve the issue.
Please help :)
Lynne
02-22-2010, 09:50 PM
Did you try printing out the value of $post[postcount] to see what was going on? It should work. You are using the postbit template and not the postbit_legacy template, right?
utahraves
02-22-2010, 11:11 PM
Correct. I am using the postbit template and not postbit_legacy.
I typed in $post[postcount] in the postbit ---
It put 5 "$post[postcount]" underneath the first post but not under any other posts (I'd expect it to do it under EACH post, not at the end of the first post).
I replaced the $post[postcount] with {vb:raw post.postcount} and refreshed, now under the first post I see "1 2 3 4 5" --- There are 5 posts in this thread.
Edit: I have also disabled all of my modifications to see if it was a mod and I am still able to produce. :(
Lynne
02-23-2010, 12:58 AM
I just put that code into my postbit template and it shows up in post 5 and 10 of my 12 post thread. Are you sure it isn't in the page source at all?
utahraves
02-23-2010, 04:55 PM
Well I feel like a complete idiot. I wasn't really paying attention to the code I was putting in between those fields. I was accidentally putting a counter code in the postbit instead of the banner code. I feel completely ridiculous - I have a cold from Hell and it is totally screwing with me.
Thanks Lynne - always appreciate your help.
Edit: So I put the right code in --- but the DIV attachments is spreading from post 1 to post 5 and ends with the banner, starts up again post 6 and ends with post 10... maybe I have to RE-revert my templates... *hates doing this*
Lynne
02-23-2010, 08:22 PM
Check your code that you closed your tags correctly.
cmiller1014
03-30-2010, 07:37 PM
Thanks guys! This worked great!!
Curious Too
10-06-2016, 11:50 AM
I tried this code with VBulletin 4.2.3 and it only shows the ad after the 5th post. What needs to change so that it shows an ad every 5th post?
<vb:if condition="(THIS_SCRIPT == showthread) AND (($post[postcount] % 5) == 0)">
Paul M
10-06-2016, 02:45 PM
Wow, 6.5 year old thread .....
As posted, that will generate at least two php warnings, it should be 'showthread' not showthread (i.e. with single quotes), postcount should also be [single] quoted.
Curious Too
10-06-2016, 04:56 PM
Wow, 6.5 year old thread .....
As posted, that will generate at least two php warnings, it should be 'showthread' not showthread (i.e. with single quotes), postcount should also be [single] quoted.
Thanks. The ad shows but does not repeat every 5 posts -- it only shows after the 5th post.
if condition="(THIS_SCRIPT == 'showthread') AND (($post['postcount'] % 5) == 0)
Is this the correct conditional for showing an ad every x number of posts?
Paul M
10-07-2016, 12:31 PM
Impossible to be sure without some sort of context.
What code is around it, where have you actually put this ?
Curious Too
10-07-2016, 03:22 PM
Impossible to be sure without some sort of context.
What code is around it, where have you actually put this ?
I have this at the end of the postbit legacy template. I'm trying to get an ad to show every x number of posts.
Lynne
10-07-2016, 09:02 PM
I just added this code to the very end of my postbit_legacy template and it shows after post 5, 10, 15, and 20 (other than the formatting being bad):
<vb:if condition="(THIS_SCRIPT == 'showthread') AND (($post['postcount'] % 5) == 0)">
<div class="attachments" align=center>
This is a test.
</div>
</vb:if>
Curious Too
10-08-2016, 09:54 AM
Thank you Lynne. It works by itself but when I combine it with another conditional to only shoe the ad in specific forums it only shows the ad once:
<vb:if condition="(THIS_SCRIPT == 'showthread') AND (($post['postcount'] % 5) == 0) AND in_array($GLOBALS['forumid'], array(419,232))">
Any ideas?
Paul M
10-08-2016, 12:55 PM
How about you post the full code you are using.
First you post some snippet and claim it doesnt work (when it looks fine).
Lynne uses that exact same code, which works, and now suddenly it works for you ?
Except you now you claim some other code doesnt work (which again, on the face of it, looks fine).
We cannot help you if you dont give us all the information.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.