Copied to clipboard

Flag this post as spam?

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


  • thanhtien501 28 posts 48 karma points
    Nov 15, 2010 @ 11:08
    thanhtien501
    0

    get list all parents of the current node

    I want to get list all parents of the given node ( include its self). i write a below code: the

     

     <ul>
      <xsl:for-each select="$currentPage/ancestor-or-self::node">
        <li><xsl:value-of select="@nodeName"/> </li>
      </xsl:for-each>
      </ul>

    (PS: i consult from the xpath in the :http://videochatisnotmagical.umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts article)

    But nothing appears and it takes a lot of  my time.

    Any help would be appreciate.

  • Rich Green 2246 posts 4008 karma points
    Nov 15, 2010 @ 11:32
    Rich Green
    0

    Which version of Umbraco are you using?

    Rich

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Nov 15, 2010 @ 11:44
    Lee Kelleher
    0

    Hi thanhtien501,

    Your XSLT looks correct.  Not sure why it would be taking a lot of time - it should be quite fast.

    If you are using the new XML schema, which is default in Umbraco v4.5 ... then you'll need to switch the "node" to "*[@isDoc]", like so:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc]">

    Cheers, Lee.

  • thanhtien501 28 posts 48 karma points
    Nov 15, 2010 @ 12:42
    thanhtien501
    0

    Hi Huge help. it runs well.

    well i'm using 4.6.0 alpha

    Lee kelleher: it takes me a lot of time to find the error in the xslt code.

     

     

     

     

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Nov 15, 2010 @ 12:44
    Lee Kelleher
    0

    @thanhtien501: I know what you mean. Debugging XSLT isn't the easiest!  If you have Visual Studio 2010 Pro, you can debug XSLT directly - eases the pain! ;-)

    More info here: http://netaddicts.be/articles/xslt-debugging-your-umbraco-powered-website.aspx

  • 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