Hi,
I am using a slightly modified "Pulldown Menu" XSLT based on the standard templates in Umbraco. I would like some help with excluding certain document types from the generated menu list.
Here is my existing code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<script type="text/javascript">
<xsl:text disable-output-escaping="yes"><!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById("pulldown_nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></xsl:text>
</script>
<xsl:call-template name="DisplayMenuList">
<xsl:with-param name="node" select="$currentPage/ancestor-or-self::node [@level = 1]"/>
<xsl:with-param name="id" select="string('pulldown_nav')"/>
<xsl:with-param name="menuDepth" select="1"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="DisplayMenuList">
<xsl:param name="node"/>
<xsl:param name="id"/>
<xsl:param name="menuDepth"/>
<xsl:variable name="maxMenuDepth" select="3"/>
<xsl:if test="$menuDepth < $maxMenuDepth">
<ul>
<xsl:if test="$id != ''">
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="$node/node [@nodeTypeAlias != 'dtNewsItem' and @nodeTypeAlias != 'dtEmploymentItem' and @level > 0]">
<li>
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<div>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</div>
<xsl:if test="count(./node) > 0">
<xsl:call-template name="DisplayMenuList">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="menuDepth" select="$menuDepth+1"/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I am trying to exclude document types with aliases of dtNewsItem and dteEmploymentItem. Currently, the menu generation goes wrong immediately after the Employment section where it is incorrectly adding another <ul> tag and nesting any following menu items instead of skipping the addition of a new <ul> for the employment items.
The employment section top menu contains ONLY employment items (dtEmploymentItem).
Where have I gone wrong?
Thanks in advance.
Tony Forgan