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

help with loops

Discussion in 'Styling and Customization Questions' started by Staxed, May 28, 2011.

  1. Staxed

    Staxed 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:

    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.
     

    Attached Files:

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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}', ','}
    
     
    Staxed likes this.

Share This Page