"Advanced" usage of position() in a list of items? Start at one number end at another.
Ok, this is hopefully quick but i couldnt find anything about it.
I have a list of articles, and that works and all, there was two things that needed to be done with it:
1: Specific styling for the first item in the list 2: Specific styling for the rest 3: And limit the number.
Ive finally begun to get my head around position() and i suceeded in the first and second point.
But! the way ive done it, i dont know how to limit the number of items then, can position have two statements? Like "start from number 2 stop at 4" or something.
<xsl:variable name="level" select="4"/>
<xsl:template match="/">
<!-- The fun starts here --> <ul class="list green"> <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:sort select="articleDate[normalize-space()]" order="descending" /> <xsl:sort select="@updateDate[not(normalize-space(../articleDate))]" order="descending" /> <xsl:choose> <xsl:when test="position() = 1"> <li class="feature"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">selected</xsl:attribute> </xsl:if> <xsl:if test="count(current()/outputPictures) > 0"> <img src="/ImageGen.ashx?image={current()/outputPictures[position()=1]/DAMP[@fullMedia]/mediaItem/Image/umbracoFile}&width=300&height=135"
width="300" height="135"/> </xsl:if> <h5><xsl:value-of select="articleHeading"/></h5> <p class="teaser"><xsl:value-of select="umbraco.library:TruncateString(artikel-Teasertekst,70,'...')"/></p> </a> </li> </xsl:when> <xsl:when test="position() >= 2"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">selected</xsl:attribute> </xsl:if> <xsl:if test="count(current()/outputPictures) > 0"> <img src="/ImageGen.ashx?image={current()/outputPictures[position()=1]/DAMP[@fullMedia]/mediaItem/Image/umbracoFile}&width=125&height=70"
width="125" height="70"/> </xsl:if> <h5><xsl:value-of select="articleHeading"/></h5> <p class="teaser"><xsl:value-of select="umbraco.library:TruncateString(artikel-Teasertekst,70,'...')"/></p> </a> </li> </xsl:when> </xsl:choose> </xsl:for-each> </ul>
Okay this is wierd indeed, i did the exact same solution you did, before making this thread, and it didnt work, thats why i came here. And now it does, this is so confusing sometimes. But thank you for your time, its much appreciated :)
"Advanced" usage of position() in a list of items? Start at one number end at another.
Ok, this is hopefully quick but i couldnt find anything about it.
I have a list of articles, and that works and all, there was two things that needed to be done with it:
1: Specific styling for the first item in the list
2: Specific styling for the rest
3: And limit the number.
Ive finally begun to get my head around position() and i suceeded in the first and second point.
But! the way ive done it, i dont know how to limit the number of items then, can position have two statements? Like "start from number 2 stop at 4" or something.
Ive highlighted the lines where i use position.
Hi,
How about
Hope this helps.
Regards,
/Dirk
Okay this is wierd indeed, i did the exact same solution you did, before making this thread, and it didnt work, thats why i came here. And now it does, this is so confusing sometimes. But thank you for your time, its much appreciated :)
is working on a reply...