Copied to clipboard

Flag this post as spam?

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


  • amein 2 posts 30 karma points
    Jul 23, 2009 @ 20:35
    amein
    0

    Get subpage from a specific parent.

    I am an absolute xslt beginner and am developing my first umbraco application.

    I want to list all the sub nodes of a parent where the name of the parent remains fixed.

    Here is my node structure

    Home
    -Abc
    -efg
    -hij

    About Us
    -blah
    -blah

    i want to write an xslt file where it always returns the children of Home. Even when i am navigation thru the about us page.

    I only want the results to be one level deep.

    I know there is a topic like this on umbraco forums but i have tried that and its not working for me[me=umbraco beginner].

    Any help would be greatly appreciated.

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 23, 2009 @ 20:49
    Dirk De Grave
    0

    Hi amein,

     

    Here's a start:

     

    <xsl:variable name="homeNodeId" select="/macro/homeNodeId" />
    <ul>
      <xsl:for-each select="umbraco.library:GetXmlNodeById($homeNodeId)/node">
        <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></li>
      </xsl:for-each>
    </ul>

     

    In above snippet, homeNodeId is a parameter you'd pass from the macro (that references the xslt file) onto the xslt. Alias for that parameter should be (for this example) homeNodeId.

     

    Hope this helps.

     

    Regards,

    /Dirk

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 23, 2009 @ 20:54
    Morten Bock
    100

    Try to start out with the built in "List subpages from a changeable source" xslt template.

    Then look at this line:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1']">

    Here you need to change the $source to the ID of your home node. You could do it by hardcoding the ID:

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1234)/node [string(data [@alias='umbracoNaviHide']) != '1']">

    Or by getting the ID in the variable by page name in the variable (a bit further up in the file):

    <xsl:variable name="source" select="$currentPage/ancestor-or-self::root/descendant::node [@nodeName = 'Home'][1]/@id"/>

    Try it out :-)

     

     

     

     

  • amein 2 posts 30 karma points
    Jul 23, 2009 @ 21:42
    amein
    0

    Thank you guys that works great...

Please Sign in or register to post replies

Write your reply to:

Draft