Copied to clipboard

Flag this post as spam?

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


  • Nico 16 posts 37 karma points
    Feb 05, 2011 @ 03:06
    Nico
    0

    for-each select by path

    Hi all,

       I've done many search (manybe wrong) and I think I come to topics responding for previous version of Umbraco so, I'm a little confused...

      I have a Content structure as

       Default
          Projects
          Contacts
          etc...

       I need to do a simple for-each select using a known path of a node in xslt. I've tried somethings like

              <xsl:for-each select="//Default/Projects">
       or
              <xsl:for-each select="$currentPage/ancestor-or-self::root/* [@nodeName = 'Projets']/nodes">


       but with no results.

       Anybody have a hint ?

       Thanks in advance.
       NF

  • Daniel Bardi 927 posts 2562 karma points
    Feb 05, 2011 @ 10:24
    Daniel Bardi
    0

    Try this:

    <xsl:for-each select="$currentPage/* [name() = 'Projects']">

    But if you know the path and it's only one node just do this:

    <xsl:variable name="projectsNode" select="$currentPage/* [name() = 'Projects' and position() = 1]"/>

    looks like it should work.

  • Nico 16 posts 37 karma points
    Feb 05, 2011 @ 17:49
    Nico
    0

    Hi,

       thanks for your answer but, it seems not to work... my Projects node is in the root node, not necessarly in the $currentPage.

       A simple test like this :

                <xsl:for-each select="$currentPage/* [name() = 'Projects']">
                  bla
                </xsl:for-each>

       is not working.

       NF

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 05, 2011 @ 21:08
    Kim Andersen
    1

    Hi Nico

    If you want to iterate through the childnodes of the "Projects"-node you should be able to use this piece og code:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc and @level='1']/*[@nodeName = 'Projects' and @isDoc]/*[@isDoc]">

    /Kim A

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 09, 2011 @ 18:22
    Kim Andersen
    0

    Hi Nico

    Did you ever find a solution to this problem?

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft