Copied to clipboard

Flag this post as spam?

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


  • dygfloyd 13 posts 24 karma points
    Dec 03, 2009 @ 00:02
    dygfloyd
    0

    Dynamically build for-each condition

    Hey everyone, I have a whole bunch of nodes that I want to filter based on a querystring. Rather than build a bunch of nested "for-each" loops, I figured it would be better to build a condition dynamically and pass that to my select. Here is what I have so far:

      <xsl:variable name="SearchFilter">data[@alias='Product_Type'] = 'Retail'</xsl:variable>
      ... more code to customize SearchFilter ..
     
      <xsl:for-each select="umbraco.library:GetXmlAll()/descendant-or-self::node[$SearchFilter]">
         ... code to display remaining nodes ...
      </xsl:for-each>

    Does anyone have any ideas to get this to work?

    Thanks!

  • dygfloyd 13 posts 24 karma points
    Dec 04, 2009 @ 04:47
    dygfloyd
    0

    Just in case anyone is curious, after much research and head banging, I think I have concluded that what I was trying to do cannot be done. I've seen it done on simple conditions that do not contain logic. ([@level=$level]) But not with statements like the one I was trying to include. (ie: The comparison data[@alias='Product_Type'] = 'Retail') I tried creating subtemplates and quite a few other options with the same results every time. I finally ended up solving the problem with what I feel is an inelegant solution using a really complicated "AND/OR" statement. (Note: I'd be happy to post the code if someone wants to see it but, like I said, it's pretty ugly.)

    If anyone knows of a way to do this or if there is trick I haven't tried, please feel free to post here. If I find something, I will do the same.

    Thanks again!

  • Tommy Poulsen 514 posts 708 karma points
    Dec 04, 2009 @ 09:26
    Tommy Poulsen
    0

    Dygfloyd, could you elaborate a bit on what your input is, and what you actually want to aquire - maybe a couple of examples of your SearchFilter ?

     

  • 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