![]() |
Adding a counter for template conditionals
Hi,
I have a simple script that lists the users with the highest reputation. I want to add the avatars of the top three results. I figure the best way was to use a template conditional like <if condition="count > 3">no avatar</else>avatar</if>. So can I accomplish this in this script: PHP Code:
|
up.
|
You probably need to grab more than the avatarvision in order to output the avatar.... unless you have the avatars in the file system - do you? Where are you wanting to put this condition?
Template: HTML Code:
<if condition="$count > 3"> PHP Code:
|
Revisting an old thread here, and I will try and reword it better as my needs have changed slightly.
Basically I have some code outputs a list of users based on the column 'credits' in the 'user' table, ie: PHP Code:
1. exampleuserA 2. exampleuserB 3. exampleuserC So I can add some sort of variable to my template like $user[count]. I want to be able to user conditionals like <if condition="$user[count] == 1 <span class="bigusername">exampleuserA</span></if> I hope it makes more sense now. PHP Code:
|
I'm not sure of exactly what you want, but maybe this is kinda it:
PHP Code:
|
lynne it works perfectly, ty so much once again. if IB isnt paying you they should be and if they are you deserve a raise!
|
Hi lynne,
revisting this thread once again. I have a different script but I ma trying to accomplish the same thing. What am I doing wrong here: Code:
<?php |
Bump. anybody help a brother out here?
|
Another bump.
Someone has to know how I can do this, it seems so simple on the surface. I cant figure out why it works in the first script I posted but in the 2nd very similar script it doesnt. Can someone please have a look for me? |
Well, for one thing the second script is for vB 4.0 (but maybe you know that?).
It might help if you said more about what it's doing and what's going wrong. |
Yep I a m aware the second script is for 4.0
And the problem is it isnt doing anything lol. If I add $count to the template it doesnt return a number, it just returns '$count' I tried {vb:raw count} and {vb:raw top_reputation.count} as well. Of course neither worked. I know this should be simple but I am not a coder unfortunately. Here is the template: Code:
<tr> Does that help you realize what I'm looking for? |
You need to register the count variable first.
add Code:
$templater->register('count',$count); Code:
$templater = vB_Template::create('adv_portal_top_reputations_bit'); |
Youre the man dartho, thanks
|
If this is all VB4 what is it in the VB3 forum for?
|
Quote:
|
All times are GMT. The time now is 02: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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|