PDA

View Full Version : How to check number of posts within template?


aciurczak
12-31-2008, 07:28 PM
Having a strange issue. I want to change the postbit slightly depending on whether users have > 1000 posts or not. I edited to postbit legacy template, and added this code:


<if condition="$post[posts]<1000">
<div>$vbphrase[posts]: $post[posts]</div>
<else />
<div>$vbphrase[posts]: A lot.</div>
</if>


and it's behaving strangely. If I change the threshold to 500, it partially works. Those with post counts between 500 & 1000 show up with the "A Lot", but unfortunately once they go over 1000 posts, once again it just shows their post count. What I think is happening is that $post[posts] is not an integer, and is really a string. So when there is a comma in that string (which there is at 1,000), it no longer resolves the comparison correctly. What is the command to add a variable and make it the integer of $post[posts]? I tried the php commands, but it doesn't seem to work.

Thanks for any suggestions.

--------------- Added 1230769047 at 1230769047 ---------------

Found a way to do it with a plug-in. Created a plug-in at the:

postbit_display_start hook

The plug-in has this code in it:

$postnum = (int)$post[posts];

Then I changed the template to use "if $postnum<1000" instead of "if $post[posts]<1000", and it works as I wanted it to.

Dismounted
01-01-2009, 03:24 AM
"Posts: A Lot" - I like it! :p