XF 1.5 Foreach loop

Lee

Well-known member
I have this loop that i'm using in my heavily cutomised profile page. It selects every post to be submitted to the users profile. Is there a way to limit the amount of records selected?

<xen:foreach loop="$profilePosts" value="$profilePost"> </xen:foreach>
 

Chris D

XenForo developer
Staff member
You can add an i attribute to the loop and each iteration will increment i by one:

Code:
<xen:foreach loop="$profilePosts" value="$profilePost" i="$i">
    <xen:if is="$i < 5">
         // Do something
    </xen:if>
</xen:foreach>
 

Chris D

XenForo developer
Staff member
Sorry:

Code:
<xen:foreach loop="$profilePosts" value="$profilePost" i="$i">
    <xen:if is="{$i} < 5">
         // Do something
    </xen:if>
</xen:foreach>
 
Top