Copied to clipboard

Flag this post as spam?

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


  • Hudhaifa Yoosuf 28 posts 97 karma points
    Apr 09, 2014 @ 05:35
    Hudhaifa Yoosuf
    0

    Wanna Get Children Nodes Of A Child Of The Parent From The Parent Page

    I need to fet all the children of News Node While Staying in The Top Most Parent?

    any help?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 09, 2014 @ 09:13
    Chriztian Steinmeier
    1

    Hi Hudhaifa,

    Here's the basics of doing something like that:

    Note that I've included three ways of getting to the "News" node - the best way is the one using the DocumentType Alias, but we can't know that from your screenshot, so it's commented out. But it's the one that'll work even if the client decides to change the name of the node (or if the macro should work in multiple language versions).

    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="umbraco.library"
    >
    
        <xsl:output method="hml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <!-- Find the topmost node regardless of where the macro runs -->
        <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
        <!-- Find the News node by DocumentType Alias -->
        <!-- <xsl:variable name="newsRoot" select="$siteRoot/News" /> -->
    
        <!-- Find the News node by its name -->
        <xsl:variable name="newsRoot" select="$siteRoot/*[@nodeName = 'News']" />
    
        <!-- Find the News node by id -->
        <!-- <xsl:variable name="newsRoot" select="$siteRoot/*[@id = 1234]" /> -->
    
        <xsl:template match="/">
            <!-- Process all the News node's children (that are not hidden) -->
            <xsl:apply-templates select="$newsRoot/*[@isDoc][not(umbracoNaviHide = 1)]" />
        </xsl:template>
    
        <!-- Generic template for any document -->
        <xsl:template match="*[@isDoc]">
            <p>
                <xsl:value-of select="@nodeName" />
            </p>
        </xsl:template>
    
    </xsl:stylesheet>
    

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft