Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've just revisited Christian Steinmeiers talk on templates from CG'10, and its really great. It inspired me to use a template to hide a specific document type from a menu. But it doesnt really work, so i need a pointer in the right direction
The document type is called "Produkt"
Ive tried:
<xsl:template match="*[@nodeTypeAlias = 'Produkt']" />
And a couple of other desperate attempts but nothing... :|
Hi Claus,
Thanks - glad you liked it :-)
This will only work in close collaboration with the apply-templates instruction, not by itself.
The very basic setup is something like this (you're using 4.0, right?)
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" exclude-result-prefixes="umb" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:param name="currentPage" /> <xsl:template match="/"> <h1>Pages below <xsl:value-of select="$currentPage/@nodeName" /></h1> <!-- Process all child pages of currentPage --> <xsl:apply-templates select="$currentPage/node" /> </xsl:template> <xsl:template match="node[@nodeTypeAlias = 'Tekstside']"> <h2><xsl:value-of select="@nodeName" /></h2> </xsl:template> <!-- Hide all Produkt documents --> <xsl:template match="node[@nodeTypeAlias = 'Produkt']" /> </xsl:stylesheet>
Here, using apply-templates, the processor will take all the child pages of currentPage and find a matching template for each of them in turn.
/Chriztian
4.5 actually, but thanks, i think i get the point
OK - the use of @nodeTypeAlias threw me off the hook then - 4.5 is so much better :-)
For those who might get here looking for help - the 4.5 version of the above would be - note how much simpler the matches are:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" exclude-result-prefixes="umb" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:param name="currentPage" /> <xsl:template match="/"> <h1>Pages below <xsl:value-of select="$currentPage/@nodeName" /></h1> <!-- Process all child pages of currentPage --> <xsl:apply-templates select="$currentPage/*[@isDoc]" /> </xsl:template> <!-- Template for Tekstside documents --> <xsl:template match="Tekstside"> <h2><xsl:value-of select="@nodeName" /></h2> </xsl:template> <!-- Hide all Produkt documents --> <xsl:template match="Produkt" /> </xsl:stylesheet>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Hide document type using xsl:template
I've just revisited Christian Steinmeiers talk on templates from CG'10, and its really great.
It inspired me to use a template to hide a specific document type from a menu.
But it doesnt really work, so i need a pointer in the right direction
The document type is called "Produkt"
Ive tried:
And a couple of other desperate attempts but nothing... :|
Hi Claus,
Thanks - glad you liked it :-)
This will only work in close collaboration with the apply-templates instruction, not by itself.
The very basic setup is something like this (you're using 4.0, right?)
Here, using apply-templates, the processor will take all the child pages of currentPage and find a matching template for each of them in turn.
/Chriztian
4.5 actually, but thanks, i think i get the point
OK - the use of @nodeTypeAlias threw me off the hook then - 4.5 is so much better :-)
For those who might get here looking for help - the 4.5 version of the above would be - note how much simpler the matches are:
/Chriztian
is working on a reply...