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!
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!
You can use the buildin template "List Sub Pages From A Changable Source" when creating a xslt in Umbraco
Ron
Using xsl:sort you can order these items.
You can limit the amount of items by using:
Ron
I will try that, thanks for you help!
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) > 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>
There are two way of acomplishing this.
You can add an parameter to your macro or u can change:
into
Where 1234 is the id of your parent.
Ron
Thank you, works great! Such a simple solution.
Your welcome, please select the solution to close this post.
is working on a reply...