The not-closing ul: You sure that the ul is actually not just collapsing. If theres no nodes to run through, then the ul will be empty resulting in the element collapsing. Try inserting a
<li> </li>
just before the </ul> and outside the for-each loop.
This would mean that here will always be at least one li-element inside the ul. The li could have a class called something like hide, and then say this in your css:
1) Make a test to ensure the <ul> is only written to the source if nodes are present - having an empty <ul> in the source does not make any sense at all in my world
2) If for some reason the above suggestion is not possible to do, then I would insert an <xsl:comment />, which makes sure the <ul> does not collapse and the layout of the page is not messed up.
3) If you can't get the above to work I would try to change the output method from XML to HTML since the empty <ul> will not collapse when rendered as HTML instead of XML. But this can mess up other parts of the layout in some cases.
Using a .hide class should be the last thing to try out IMHO :-)
Test if current page has no sub pages.
Hi All,
I have the following xslt for the 4.5 schema:
So far so good but I need a little help in resolving the following to points:
For item 1, I tried wrapping an if statement around with the following, but the menu items are hidden on all pages.
Any help or pointers would be greatly appericated.
Thanks in advance
Eddie
You should be fine with just this:
When doing a test=, then it will bu true, if the xpath statement has any results. If not, it will be false.
Hi Morten,
Cool, this works well on the parent page and displays the buttons. However, when I view a sub page the buttons are not displayed.
Any thoughts on the closing <ul class="nav-btns">, when the current page has no sub pages.
Thanks again,
Eddie
Hi Eddie
The not-closing ul: You sure that the ul is actually not just collapsing. If theres no nodes to run through, then the ul will be empty resulting in the element collapsing. Try inserting a
just before the </ul> and outside the for-each loop.
This would mean that here will always be at least one li-element inside the ul. The li could have a class called something like hide, and then say this in your css:
UPDATE: The <li> above should contain a
/Kim A
Hi Eddie
I would either do
1) Make a test to ensure the <ul> is only written to the source if nodes are present - having an empty <ul> in the source does not make any sense at all in my world
2) If for some reason the above suggestion is not possible to do, then I would insert an <xsl:comment />, which makes sure the <ul> does not collapse and the layout of the page is not messed up.
3) If you can't get the above to work I would try to change the output method from XML to HTML since the empty <ul> will not collapse when rendered as HTML instead of XML. But this can mess up other parts of the layout in some cases.
Using a .hide class should be the last thing to try out IMHO :-)
/Jan
Yeah like Jan says, the best solution probably would be to check to see if there is any nodes before rendering the ul at all. Something like this:
<xsl:if test="count($currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']) > 0>
wrapped around the entire ul.
/Kim A
Hi All,
Thanks for the all the advice.
Ended up puting the check before the first div, which has resolved both of the issues.
Thanks again.
Eddie
is working on a reply...