Copied to clipboard

Flag this post as spam?

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


  • anthony hall 222 posts 536 karma points
    Jul 12, 2009 @ 10:31
    anthony hall
    0

    reassign values to params

    Is it possible to reassign values to params? I'm trying to use param as global variable in c# talk. 

     

    <xsl:param  name="SelectedRegion" select="" />

    <xsl:for-each select="$currentPage/../node [@nodeTypeAlias = 'Assets']/child::node">

  • Tommy Poulsen 514 posts 708 karma points
    Jul 12, 2009 @ 11:15
    Tommy Poulsen
    1

    Hi Anthony, you cannot reassign variables or parameters, but within the loop you can initialize a variable to the specified select, e.g. something like this:

    <xsl:for-each ...>
    <xsl:variable name="LoopSelectedRegion" select="data [@alias ='region']"/>
    ...
    </xsl:for-each>

    >Tommy

  • anthony hall 222 posts 536 karma points
    Jul 12, 2009 @ 12:36
    anthony hall
    0

    ah ok, thanks for clearing that up. 

    So, i'm not sure if i can achieve this with xslt. I need to get @alias ='region' of the previous item in the foreach. I see the preceeding axis is not supported yet. 

    http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts

    Also i have an 'if statement' just  after my foreach so i don't alway want the preceeding items. Hmm,  usercontrol?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 12, 2009 @ 17:27
    Morten Bock
    1

    I think all the axis types are supported, they are just not in the book you linked to.

    I don't know your current script, but maybe it could be possible to take the <xsl:if ... /> part out of it, and incorporate that part into your for-each xpath instead?

    <xsl:for-each select="$currentPage/../node [@nodeTypeAlias = 'Assets']/child::node [data [@alias ='region'] != $SelectedRegion]">
    <xsl:value-of select="data [@alias ='region']" />
    </xsl:for-each>

    Another approach would be do the loop recursively using the <xsl:call-template> tag.

     

  • anthony hall 222 posts 536 karma points
    Jul 13, 2009 @ 08:50
    anthony hall
    0

    cool, thank morten.

    I didn't realise you could incorporate the if with the for each. Do you have any examples of <span style="white-space: pre-wrap;"> <xsl:call-template></span>

    Thanks, Anthony

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 13, 2009 @ 09:26
    Dirk De Grave
    1

    Anthony,

     

    The sitemap xslt (which is available from the dropdown when creating an xslt) does have an example on how to use templates recursively.

    (File on disk can be found at /umbraco/xslt/templates/Sitemap.xslt

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft