Addressing a specific node in a for each select= statement
Hi
I am very new to Umbraco and xslt and am on the very steep bit of my earning curve!
Using
Umbraco 4.5.2 I have modified (with a lot of help from Dirk on here) a
standard runway xslt file to provide me with a thumnail link to each sub
gallery in the node gallery in the structure below when navigating to
Galleries:
Home page
Node1
Node2
Node3
Galleries
Gallery1
Gallery2
The ror each statement is <xsl:for-each select="$currentPage/* [@isDoc]">
I'd
like to use the concept in a more general sense as a sort of menu in
another site I am about to build so that I can include the macro in a
master page so that in a structure like:
Home Page
About Us
Service1
Service2
I can get a thumbnail for each of the nodes.
To see if I could emulate the success of <xsl:for-each
select="$currentPage/* [@isDoc]"> but using a specific node name I
have experimented in my current site (top example) using:
<xsl:for-each select="Galleries/* [@isDoc]">
<xsl:for-each select="../Galleries/* [@isDoc]">
<xsl:for-each select="./Galleries/* [@isDoc]">
Whilst not giving errors none display the thumbnails.
Addressing a specific node in a for each select= statement
Hi
I am very new to Umbraco and xslt and am on the very steep bit of my earning curve!
Using Umbraco 4.5.2 I have modified (with a lot of help from Dirk on here) a standard runway xslt file to provide me with a thumnail link to each sub gallery in the node gallery in the structure below when navigating to Galleries:
Home page
Node1
Node2
Node3
Galleries
Gallery1
Gallery2
The ror each statement is <xsl:for-each select="$currentPage/* [@isDoc]">
I'd like to use the concept in a more general sense as a sort of menu in another site I am about to build so that I can include the macro in a master page so that in a structure like:
Home Page
About Us
Service1
Service2
I can get a thumbnail for each of the nodes.
To see if I could emulate the success of <xsl:for-each select="$currentPage/* [@isDoc]"> but using a specific node name I have experimented in my current site (top example) using:
<xsl:for-each select="Galleries/* [@isDoc]">
<xsl:for-each select="../Galleries/* [@isDoc]">
<xsl:for-each select="./Galleries/* [@isDoc]">
Whilst not giving errors none display the thumbnails.
So,
1. can I address a specific node?
2. can I just use $root to address "Home Page"
First you have to find your root node:
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::* [@level = 1]"/>
Then you can list the children with something like this:
<xsl:for-each select="$rootNode/child::* [@isDoc][not(umbracoNaviHide = 1)]">
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
</xsl:for-each>
The umbracoNaviHide is useful if you have a node that you do not want to show in the navigation. Just add true/false property in the doc type.
Thanks Ernst - works a treat.
If I want to start from, say the Galleries subnode, how would I modify the xsl:variable statement?
I guessed at adding /Galleries after self::* , and instead of * :):) but no luck!
No problem Geoff :)
If the Galleries subnode has a nodetype different from its siblings you can find it by its nodetype alias:
<xsl:variable name="galleriesNode" select="$rootNode/child::Galleries [@isDoc]"/>
If the nodes use the same nodetype, you can get the gallery node by its id:
<xsl:variable name="galleriesNode" select="$rootNode/child::* [@isDoc and @id = IDOFYOURNODE]"/>
You can also get it by its name:
<xsl:variable name="galleriesNode" select="$rootNode/child::* [@isDoc and @nodeName = 'NODENAME']"/>
Once again Ernst - thank you..
Both for the solution and the mini xsl lesson!
is working on a reply...