Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all
I want to create a dropdownboxs with the 10 next coming week numbers. Basically I want to repeat this code X number of times:
<xsl:variable name="daysInFuture">P<xsl:value-of select="number(7 * position())"/>D</xsl:variable><li><a href="/details.aspx?fromdate={umbraco.library:Replace(umbraco.library:FormatDateTime(Exslt.ExsltDatesAndTimes:add($thisDate, 'P7D'), 'M-d-yyyy'), '-', '%2f')}"> Week <xsl:value-of select="Exslt.ExsltDatesAndTimes:weekinyear(Exslt.ExsltDatesAndTimes:add($thisDate, $daysInFuture))"/></a></li>
Right now I am here:
<xsl:variable name="weeksInFuture" select="'10'"/><xsl:variable name="thisWeek" select="Exslt.ExsltDatesAndTimes:weekinyear()"/><xsl:variable name="thisDate" select="Exslt.ExsltDatesAndTimes:date()"/> <xsl:template match="/"> <p><xsl:value-of select="$weeksInFuture"/><br /><xsl:value-of select="$thisWeek"/><br /><xsl:value-of select="$thisDate"/></p> <ul> <xsl:for-each select=" ??? "> <xsl:apply-templates /> </xsl:for-each> </ul></xsl:template> <xsl:template match="/"> <xsl:variable name="daysInFuture">P<xsl:value-of select="number(7 * position())"/>D</xsl:variable> <li><a href="/details.aspx?fromdate={umbraco.library:Replace(umbraco.library:FormatDateTime(Exslt.ExsltDatesAndTimes:add($thisDate, 'P7D'), 'M-d-yyyy'), '-', '%2f')}"> Week <xsl:value-of select="Exslt.ExsltDatesAndTimes:weekinyear(Exslt.ExsltDatesAndTimes:add($thisDate, $daysInFuture))"/></a></li></xsl:template>
But I don't know how to provoke a loop, with having something to loop through...?
Hi Kasper,
For this, you would usually use a recursive template (one that calls itself, unless some condition is met).
Simple example:
<xsl:template match="/"> <!-- Start repeating --> <xsl:call-template name="repeatable" /> </xsl:template> <xsl:template name="repeatable"> <xsl:param name="index" select="1" /> <xsl:param name="total" select="10" /> <!-- Do something --> <xsl:if test="not($index = $total)"> <xsl:call-template name="repeatable"> <xsl:with-param name="index" select="$index + 1" /> </xsl:call-template> </xsl:if> </xsl:template>
/Chriztian
Change the weeksInFuture variable like so:
<xsl:variable name="weeksInFuture" select="'1,2,3,4,5,6,7,8,9,10'"/>
and now the for each loop can be:
<xsl:for-each select="Exslt.ExsltStrings:split($weeksInFuture,',')">
- For a more elaborate example (and craziness), check this Gist out: https://gist.github.com/839751
Yeay, Chriztian! It works.
Thanks a lot
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Loop this code 10 times
Hi all
I want to create a dropdownboxs with the 10 next coming week numbers. Basically I want to repeat this code X number of times:
Right now I am here:
But I don't know how to provoke a loop, with having something to loop through...?
Hi Kasper,
For this, you would usually use a recursive template (one that calls itself, unless some condition is met).
Simple example:
/Chriztian
Change the weeksInFuture variable like so:
<xsl:variable name="weeksInFuture" select="'1,2,3,4,5,6,7,8,9,10'"/>
and now the for each loop can be:
<xsl:for-each select="Exslt.ExsltStrings:split($weeksInFuture,',')">
- For a more elaborate example (and craziness), check this Gist out: https://gist.github.com/839751
/Chriztian
Yeay, Chriztian! It works.
Thanks a lot
is working on a reply...