• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

"For" loop within template

semprot

Active member
#1
How to create "for" loop within template? I only see "foreach" loop example.

I have an integer variable called $a which has a numeric value.
I want to do something on template like
PHP:
<?php for ($i = 1; $i < $a; $i++) : ?>
<b>Hello World</b>
<?php endfor; ?>
 

semprot

Active member
#4
For example i have this code on my template
PHP:
{xen:number $user.reputation_count}
First example : if $user.reputation_count is 5, i want to print 5 asterisks.
Second example : if $user.reputation_count is 10, i want to print 10 asterisks.

Is there something like this?
PHP:
<xen:for "$user.reputation_count">
    <span style="color:#F00">*</span>
</xen:for>
 

Chris D

XenForo developer
Staff member
#5
This would have the same effect:
Code:
<xen:if is="{$user.reputation_count}">
    <span style="color: #F00">{xen:string repeat, '*', $user.reputation_count}</span>
</xen:if>
 

AndyB

Well-known member
#6
What are the limits for this reputation count? You wouldn't want to print 100 asterisks I assume. Is it more like a star rating system with 5 stars maximum?
 

semprot

Active member
#7
This would have the same effect:
Code:
<xen:if is="{$user.reputation_count}">
    <span style="color: #F00">{xen:string repeat, '*', $user.reputation_count}</span>
</xen:if>
Thank you, i think this works :)

What are the limits for this reputation count? You wouldn't want to print 100 asterisks I assume. Is it more like a star rating system with 5 stars maximum?
At this moment it is 5 stars max :)