However, sometimes there isn't any level 2 navigation for the page. When this happens, the above macro renders an opening list tag (<ul id="page-nav">) but doesn't close it. It somehow doesn't recognise that there's a </ul> at the end. So this breaks my HTML and the layout goes wrong.
Can anyone see how to fix this, or even check that there are items there before writing out the opening list tag?
So if there are no nodes to display, then it wont output the <ul> tags. Personally I'd extend this so that the "$currentPage/node[string(data[@alias='umbracoNaviHide']) != '1']" is in an xsl:variable - saves calling the same XPath twice!
XSLT navigation not closing properly
Hi,
I've got a macro which lists all level 2 navigation on a page. Here's the XSLT:
However, sometimes there isn't any level 2 navigation for the page. When this happens, the above macro renders an opening list tag (<ul id="page-nav">) but doesn't close it. It somehow doesn't recognise that there's a </ul> at the end. So this breaks my HTML and the layout goes wrong.
Can anyone see how to fix this, or even check that there are items there before writing out the opening list tag?
Thanks folks...
Hi Dan,
Just wrap your UL section in an XSL:IF statement:
Cheers,
Chris
Hi Dan,
You've got 2 options...
1. Change the output method to HTML:
This will leave you with <ul id="page-nav"></ul> - which you may or may not want.
2. Put an IF condition around the <ul> tags:
So if there are no nodes to display, then it wont output the <ul> tags. Personally I'd extend this so that the "$currentPage/node[string(data[@alias='umbracoNaviHide']) != '1']" is in an xsl:variable - saves calling the same XPath twice!
Cheers, Lee.
@Chris ... cross-posted at the same time! Great minds think alike! :-)
Thanks both, the 'if' thing works a treat. No empty list too, so it's the prefered option.
is working on a reply...