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

help with loops

Staxed

Active member
#1
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:

Code:
<xen:if is="{$TilkiBey_UsergroupLegend}">
    <xen:if hascontent="true">
        <div class="userlegend">
{xen:phrase tlk_usergrouplegend_title}:</b>
            <xen:contentcheck>
                        <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>,
                        </xen:foreach>
                    </xen:contentcheck>
        </div>
    </xen:if>
</xen:if>
I just want to remove that comma after the Member usergroup.
 

Attachments

Jake Bunce

XenForo moderator
Staff member
#2
Use this:

Code:
                        <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}', ','}
                        </xen:foreach>
I added these two pieces:

Code:
i="$i" count="$count"

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