What I Need: My secondary nav to output only the page titles
below Software, Applications, Related Products, Our Clients, and
Support. So, when I click on the Software link from the main nav, a <ul> populated with all page titles below Software should appear below the Software link. Really, I just want to exclude Home from having a <ul> of second level titles created because it will populate a list that is already seen in the main nav.
If you go to the developer section and create a new XSLT based macro you should be able to choose the "Navigation prototype" from the dropdown. Here you'll find a level macro where you can specify the levels that should be displayed in your secondary navigation.
<!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation --> <xsl:variable name="level" select="1"/>
I tried your first suggestion, and it was close, but there are a few issues.
See the image below to see how it rendered.
You'll notice how it displays all the list items at once. I am trying to make it work so that when I click on, let's say, Related Products, after the click is made, LiftTrainer, Physical Therapy, and SwingTrainer would appear.
**Only the links with a carrot should appear when the Home page is first loaded. **Secondary links should appear when their parent is clicked.
Also, you can see that there are some indentation issues with the level one items (carrot links). Any idea why that would happen? They should all be left justified.
<!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation -->
Secondary Nav - Exclusion Help
What I Need: My secondary nav to output only the page titles below Software, Applications, Related Products, Our Clients, and Support. So, when I click on the Software link from the main nav, a <ul> populated with all page titles below Software should appear below the Software link. Really, I just want to exclude Home from having a <ul> of second level titles created because it will populate a list that is already seen in the main nav.
Folder Setup:
My Secondary Level Nav 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:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1'and @nodeTypeAlias!='Home']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Hi Joe
Is this sample how your primary navigation looks?
If you go to the developer section and create a new XSLT based macro you should be able to choose the "Navigation prototype" from the dropdown. Here you'll find a level macro where you can specify the levels that should be displayed in your secondary navigation.
I think this should solve your issue? :-)
/Jan
Is the Document Type of the home page "Home"?
Or are you trying to check for the name of the node (@nodeName)?
Thanks for the responses guys!
The image sample above is my current folder configuration in umbraco. The source code above is for the secondary nav that I haven't implemented yet.
Here is how that folder setup renders with my main nav:
Here is the source code for my main nav:
<?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"/>
<!-- Input the documenttype you want here -->
<!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
<!-- Use div elements around this macro combined with css -->
<!-- for styling the navigation -->
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<!--xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']"-->
<xsl:for-each select="umbraco.library:GetXmlNodeById(1045)/node [string(data [@alias='umbracoNaviHide']) != '1']">
<a href="{umbraco.library:NiceUrl(@id)}" class="navOff">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">navOn</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">navOff</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@nodeName"/>
</a>
<!-- Secondary Navigation Tests Here -->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
What I am having trouble with is outputing the second level links below the first level links after the first level link is clicked.
Does that make sense?
@Jason - In the first code snippet I attached, I was trying to create a loop that would output second level nav links for all pages except Home.
Hope this all makes sense - a lot of writing for something so simple! :]
Is the home page the 1045 id above?
Hi Jason
Yes, that's right.
I made a small modification, but I'm not sure it will give you what you want. Does that get close?
Why can't you use the base Navigation starter macro (or even the Sitemap macro)?
I've also used something like this to accomplish what you're trying to do. Maybe this will help too.
@ Jason - Thanks for the reply :)
I tried your first suggestion, and it was close, but there are a few issues.
See the image below to see how it rendered.
You'll notice how it displays all the list items at once. I am trying to make it work so that when I click on, let's say, Related Products, after the click is made, LiftTrainer, Physical Therapy, and SwingTrainer would appear.
**Only the links with a carrot should appear when the Home page is first loaded. **Secondary links should appear when their parent is clicked.
Also, you can see that there are some indentation issues with the level one items (carrot links). Any idea why that would happen? They should all be left justified.
I think you probably need to change this:
To use your navOn/navOff classes
Also, the secondary nav didn't take into account the umbracoNaviHide. Try this:
Nearly there! The only thing I'm having trouble with now is getting the secondary links to appear only when their parent is clicked.
You said
should be used to address the navOn/navOff classes. Where exactly would that be placed?
Here is the code that works nicely as a static list:
<?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"/>
<!-- Input the documenttype you want here -->
<!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
<!-- Use div elements around this macro combined with css -->
<!-- for styling the navigation -->
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<xsl:for-each select="umbraco.library:GetXmlNodeById(1045)/node [string(data [@alias='umbracoNaviHide']) != '1']">
<a href="{umbraco.library:NiceUrl(@id)}" class="navOff">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">navOn</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">navOff</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@nodeName"/>
</a>
<!-- Secondary Nav -->
<xsl:if test="count(./child::node [string(data [@alias='umbracoNaviHide']) != '1']) > 0">
<ul>
<xsl:for-each select="./child::node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<!-- Secondary Nav -->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
So, now I just have to figure out how to hide the secondary links until their parent is clicked.
Any ideas on this one? I still can't get the secondary links to appear only after their parent is clicked. They appear fine as a static list though.
Thanks!
Sorry it took me a while to respond...
How does this work for you?
is working on a reply...