Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 954 karma points
    Mar 10, 2011 @ 02:58
    Tom
    0

    new syntax find a node with a specific id..

    hi guys I'm trying to work out under the new syntax how to find the children starting at a specific node id..

     

    i.e. root/* [@id = $startNodeID and @isDoc]/* [@isDoc]  ??? would that be the most correct way to find them?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 10, 2011 @ 09:52
    Chriztian Steinmeier
    0

    Hi Tom,

    To find a node by ID you can do either of these:

    <!-- Using XPath -->
    <xsl:variable name="node1" select="$currentPage/ancestor::root//*[@id = 1234]" />
    
    <!-- Using extension library -->
    <xsl:variable name="node2" select="umbraco.library:GetXmlNodeById(1234)" />

    Using XPath you can trim down the amount of nodes searched by adding anything you know about the location of the node your'e looking for, e.g.:

    <!-- Reference to root of site -->
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <!-- I want a NewsItem node that is a direct child node of the News node that is at the root of the site -->
    <xsl:variable name="breakingNews" select="$siteRoot/News/NewsItem[@id = 1234]" />

    /Chriztian

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 10, 2011 @ 09:57
    Chriztian Steinmeier
    0

    - ok, misread the question (mislead by the title, I guess :-)

    Yes, if you know the startnode you could just do what you did - should work fine - maybe use the DocumentType's name if you know it, e.g. NewsItem instead of the generic *[@isDoc]

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft