Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ds 191 posts 223 karma points
    Sep 21, 2010 @ 14:14
    ds
    0

    how to concatenate increased number into href tag?

    I have created such loop

     <xsl:template match="/">
    <ul class="mainTabSection">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <li>
    <xsl:variable name="i" select="position()" />
    <xsl:copy>
    <xsl:value-of select="concat('#tab', $i)"/>
    </xsl:copy>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>

    What I need to achieve is to get the following result

            <ul class="mainTabSection"> 
    <li><a href="#tab1">link name</a></li>
    <li><a href="#tab2">link name</a></li>
    <li><a href="#tab3">link name</a></li>
    </ul>

     

    but I do not know how to wrap "<a href=""></a> with increased tab number.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 21, 2010 @ 14:18
    Chriztian Steinmeier
    0

    Hi ds,

    position() is your friend:

    <a href="#tab{position()}"> ... </a>

    /Chriztian

  • ds 191 posts 223 karma points
    Sep 21, 2010 @ 14:25
    ds
    0

    Thanks Chriztian,

    I changed code snippet and it is working as it is expected.

     <xsl:template match="/">
    <ul class="mainTabSection">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <li>
    <a href="#tab{position()}"><xsl:value-of select="data [@alias = 'tabLink']"/></a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>

    thx,

    ds

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies