Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Jul 20, 2009 @ 16:12
    Amir Khan
    0

    Getting child nodes of a specific parent.

    Hi,

    I'd like to know how to get child nodes of a specific parent and put them in a template.

    For example:

    If i had a parent called "jobs" and i make a pages below it called "job1", "job2", "job3", etc. I'd like to be able to generate an unordered list of these children and put them on certain pages. I'd also like to be able to limit the list to say, the 3 most recent ones and put it on a home page or any other page.

    Not sure how to go about doing this, I have found a bunch of great info on how to get children of the "current" parent, but not how to get the children of  a specific parent. Any help would be greatly appreciated!

     

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 16:25
    Ron Brouwer
    0

    You can use the buildin template "List Sub Pages From A Changable Source" when creating a xslt in Umbraco

    Ron

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 16:28
    Ron Brouwer
    0

    Using xsl:sort you can order these items.
    You can limit the amount of items by using:

    umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1' and position() < 4]

    Ron

  • Amir Khan 1287 posts 2744 karma points
    Jul 20, 2009 @ 17:53
    Amir Khan
    0

    I will try that, thanks for you help!

  • Amir Khan 1287 posts 2744 karma points
    Jul 20, 2009 @ 18:01
    Amir Khan
    0

    Okay, the part I'm missing is how to manually define the parent.

    here where it says:     <xsl:param name="parent" />
    Id like to do something like:     <xsl:param name="mynodename" />

    <xsl:template name="drawNodes">
        <xsl:param name="parent" />
        <ul>
        <xsl:for-each select="$parent/node">
            <li>
                <xsl:value-of select="@nodeName" />
                <xsl:if test="count(./node) &gt; 0">
                    <!-- this node has children, let's list them also -->
                    <xsl:call-template name="drawNodes">
                        <xsl:with-param name="parent" select="." />
                    </xsl:call-template>
                </xsl:if>
            </li>
        </xsl:for-each>
        </ul>
    </xsl:template>

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 18:29
    Ron Brouwer
    100

    There are two way of acomplishing  this.

    You can add an parameter to your macro or u can change:

    <xsl:param name="parent" />

    into

     

    <xsl:param name="parent" select="1234"/>

    Where 1234 is the id of your parent.

    Ron

  • Amir Khan 1287 posts 2744 karma points
    Jul 20, 2009 @ 19:04
    Amir Khan
    0

    Thank you, works great! Such a simple solution.

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 19:19
    Ron Brouwer
    0

    Your welcome, please select the solution to close this post.

Please Sign in or register to post replies

Write your reply to:

Draft