View Full Version : Why i can?t get it work?
maar3amt
10-10-2008, 10:04 PM
Hi ppl
Why i can't get this code work on postbit_legancy?
<if condition="$post[posts] >= 200">
Some text
</if>
orryun
10-10-2008, 10:48 PM
Your code works fine with me.
Where exactly doesn't this code work?
Try insert DIV tags, like so: <div>Some text</div>
Lynne
10-10-2008, 10:56 PM
Maybe try $post['posts']
orryun
10-10-2008, 11:20 PM
Maybe try $post['posts']
I have tried the $post[posts] thingy and it worked nicely on vB 3.8.0 b1
I think it's about the location of the code.
Lynne
10-10-2008, 11:34 PM
I have tried the $post[posts] thingy and it worked nicely on vB 3.8.0 b1
I think it's about the location of the code.
Yeah, could be. I can never remember when to use quotes and when not to. One of these days I'll learn!
maar3amt
10-11-2008, 01:00 AM
well on left side after user avatar i want show a message if user have more than 200 posts like.
<if condition="$post[posts] >= 200">
I have more than 200 posts
</if>
<else>
I have less thab 200 posts
Lynne
10-11-2008, 03:46 AM
Well, your condition is written incorrectly:
<if condition="$post[posts] >= 200">
I have more than 200 posts
<else />
I have less thab 200 posts
</if>
Dismounted
10-11-2008, 04:19 AM
$post[posts] is equal to $post['posts'] and is also equal to $post["posts"] if no constant with the name "posts" exists. PHP will actually output a warning if you do not quote the array key. PHP actually first searches for a constant called "posts", then it looks up the array for an element with key "posts".
maar3amt
10-12-2008, 03:27 PM
Yes this code work if user ha less than 1,000 posts if have higher don't work propely.
Lynne
10-12-2008, 04:32 PM
Yes this code work if user ha less than 1,000 posts if have higher don't work propely.
Yes, that is correct. The variable is actually a formatted variable and so if you wish to do comparisons to it with numbers greater than 1,000, you need to deal with it using php code and thus in a plugin.
edit to add: You can always do the reverse comparison and it should work:
<if condition="$post[posts] <= 200">
I have less than 200 posts
<else />
I have more than 200 posts
</if>
Marco van Herwaarden
10-14-2008, 09:13 AM
edit to add: You can always do the reverse comparison and it should work:
<if condition="$post[posts] <= 200">
I have less than 200 posts
<else />
I have more than 200 posts
</if>
Nope that would not work.
Consider a user with 1100 posts. This would be formatted as "1.100".
"1.100 <= 200" will be true!! ("1.100" will be casted to a numeric and will result in "1")
Only (good) solution is to create a plugin that store the postcount in a seperated variable before it is formatted.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.