I'm trying to hide or show div items depending on what the current doc type is or what it's ancestor doc type is.
However if I try to use "ancestor-or-self" the div will display, on the current page and it's child nodes. It only works on the current page when I use "self". But it still displays on the child nodes.
You should really use the apply-templates approach for something like this - here's the basic gist of how it works:
<xsl:template match="/">
<!-- Run the template for the current page's alias -->
<xsl:apply-templates select="$currentPage" />
</xsl:template>
<!-- Custom templates -->
<xsl:template match="YourElectricityPage">
<div>
I am the Electricity Page
</div>
</xsl:template>
<xsl:template match="YourGasPage">
<div>
I am the Gas Page
</div>
</xsl:template>
This way you won't have to bend your head in a multitude of ways whenever a new page type needs to be added - you just add a new template - boom!
If you have stuff that should be output for all pages - put it in the root template (match="/"). If you need to suppress a lot of other page types (aliases) you can add a generic template to suppress everything that doesn't have its own template, e.g.:
<xsl:template match="*[@isDoc]" priority="-1">
<!-- No content here - no output for these -->
</xsl:template>
Hide div when parent is certain doc type
Hi all,
I'm trying to hide or show div items depending on what the current doc type is or what it's ancestor doc type is.
However if I try to use "ancestor-or-self" the div will display, on the current page and it's child nodes. It only works on the current page when I use "self". But it still displays on the child nodes.
Any ideas as to what will fix this?
Cheers, JV
Here's my XSLT:
Hi JV,
You should really use the apply-templates approach for something like this - here's the basic gist of how it works:
This way you won't have to bend your head in a multitude of ways whenever a new page type needs to be added - you just add a new template - boom!
If you have stuff that should be output for all pages - put it in the root template (match="/"). If you need to suppress a lot of other page types (aliases) you can add a generic template to suppress everything that doesn't have its own template, e.g.:
/Chriztian
is working on a reply...