I have a subnav XSLT script that displays all child nodes of the tree currently being viewed. This works fine. I want to 'disable' the subnav when you are viewing a certain node tree by its @id.
@Per Olsson your example will not work for me. That checks against the single node being viewed, im trying to hide an entire node tree. Basically, if you are viewing node 1148 or ANY child of, simply don't process the subnav script period.
You're actually on the right track, but the XSLT syntax you're using is for the legacy schema, which you're probably not using (Umbraco 4.1 or below, IIRC).
Here's a chunk of code that outlines how I'd approach a similar situation - note that it handles both the "hardcoded ID" scenario you're suggesting and the hideSubnav property that Per suggested:
Disable subnav when at certain node tree
I have a subnav XSLT script that displays all child nodes of the tree currently being viewed. This works fine. I want to 'disable' the subnav when you are viewing a certain node tree by its @id.
For example if you are viewing:
http://mysite.com/section1/, all of the child nodes display in the sidebar. http://mysite.com/section2/, all of the child nodes display in the sidebar. http://mysite.com/section3/, subnav display should be disabled.
http://mysite.com/section3/ has a node @id of 1148. Whether you are viewing this node or any of its children nodes, no subnav should be displayed.
The script basically works like this:
The way I see it, an IF statement needs to be put above the xsl:for-each
I can't seem to get the syntax right. Thoughts?
I would not recommend to hardcode the page ID, instead make a checkbox property on the documenttype and set it where you want to hide it.
You should be able to modify "mainNodes" variable by simply adding the following to your select (or whatever propertyname you choose):
@Per Olsson your example will not work for me. That checks against the single node being viewed, im trying to hide an entire node tree. Basically, if you are viewing node 1148 or ANY child of, simply don't process the subnav script period.
Hi Robert,
You're actually on the right track, but the XSLT syntax you're using is for the legacy schema, which you're probably not using (Umbraco 4.1 or below, IIRC).
Here's a chunk of code that outlines how I'd approach a similar situation - note that it handles both the "hardcoded ID" scenario you're suggesting and the
hideSubnav
property that Per suggested:Hope that helps,
/Chriztian
is working on a reply...