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

help with loops


Active member
I'm trying to mess with a usergroup legend modification I got from here to make it look like I want.

I haven't messed with loops that much, and I'm trying to make it so that the comma doesn't appear after the last usergroup.

This is the code it's using to generate the below result:

<xen:if is="{$TilkiBey_UsergroupLegend}">
    <xen:if hascontent="true">
        <div class="userlegend">
{xen:phrase tlk_usergrouplegend_title}:</b>
                        <xen:foreach loop="$TilkiBey_UsergroupLegend" value="$TilkiBey_UsergroupLegend">
                                    <span style="{$TilkiBey_UsergroupLegend.usergroup.username_css}" title="{$TilkiBey_UsergroupLegend.usergroup.title}">{$TilkiBey_UsergroupLegend.usergroup.title}</span>,
I just want to remove that comma after the Member usergroup.


Jake Bunce

XenForo moderator
Staff member
Use this:

                        <xen:foreach loop="$TilkiBey_UsergroupLegend" value="$TilkiBey_UsergroupLegend" i="$i" count="$count">
                                    <span style="{$TilkiBey_UsergroupLegend.usergroup.username_css}" title="{$TilkiBey_UsergroupLegend.usergroup.title}">{$TilkiBey_UsergroupLegend.usergroup.title}</span>{xen:if '{$i} != {$count}', ','}
I added these two pieces:

i="$i" count="$count"

{xen:if '{$i} != {$count}', ','}