Copied to clipboard

Flag this post as spam?

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


  • Cristian 24 posts 45 karma points
    Mar 02, 2012 @ 02:32
    Cristian
    0

    Get all id parent from currentPage

    Hi everybody

    there is a way to get all parent id Node from a certain node?

    for example

    node 1

      node2

      node3

         node4

    node5.....

    and i choose node4, but i need to know all id parents, node1-node2-node4

    there is a function in umbraco.library or some recursive templete to do this??

    regards.

     

     

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Mar 02, 2012 @ 07:32
    Markus Johansson
    0

    Are you talking about something lika a breadcrumb? I think that theres a build in template for that. But something like this:

     <xsl:for-each select="$currentPage/ancestor::* [@level &gt; $minCrumbLevel and string(umbracoNaviHide) != '1']">
           <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
             <xsl:value-of select="@nodeName"/>
           </a>
        </li>
     </xsl:for-each>

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Mar 02, 2012 @ 15:20
    Chriztian Steinmeier
    1

    Hi Cristian,

    If you just need the Ids for some reason, you can grab the @path attribute - it contains a "path of Ids" to the selected node, e.g.:

    If you have this setup:
    
    Home (id:1050)
      Node1 (id:1052)
        Node2 (id:1053)
        Node3 (id:1054)
        Node4 (id:1055)
    
    You can try:
    <xsl:value-of select="$currentPage/@path" /> <!-- Will output: -1,1050,1052,1055 -->

     

    But you don't need the Ids if you just want to access the actual nodes - the ancestor-or-self:: axis will select them for you:

    <xsl:variable name="nodesInPathToCurrent" select="$currentPage/ancestor-or-self::*[@isDoc]" />

     

    /Chriztian

  • Cristian 24 posts 45 karma points
    Mar 02, 2012 @ 15:39
    Cristian
    0

    Thanks for you reply! both of you.

    @path was the property that i was looking for!

     

  • 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