Reputation: 1605
Struggling a bit with my Umbraco xslt navigation macro. I've got the top level working, but now realize I need a second level, and also for each top level LI to have a unique class (and a selected class where appropriate). Can anyone help me out?
This is what I have so far:
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<ul id="section_navigation">
<xsl:for-each select="umbraco.library:GetXmlNodeById('1137')/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '1']) > 0">
<div class="sub">
<ul>
<xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</div>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:template>
and here's the result I'm looking for:
<ul id="section_navigation">
<li class="pal"><a href="/Pal">Pal</a></li>
<li class="memo"><a href="/memo">Memo</a>
<div class="sub">
<ul>
<li><a href="/memo/latest">Latest</a></li>
<li><a href="/memo/history">History</a></li>>
</ul>
</div>
</li>
<li class="questions"><a href="/questions">Questions</a></li>
<li class="office"><a href="/office">Office</a></li>
<li class="mail"><a href="/mail">Mail</a>
<div class="sub">
<ul>
<li><a href="/mail/mailbox">MailBox</a></li><li><a href="/mail/new-message">New Message</a></li>
</ul>
</div>
</li>
<li class="jobs"><a href="/jobs">jobs</a>
<div class="sub">
<ul>
<li><a href="/jobs/all">All</a></li>
<li><a href="/jobs/magazine">Magazine</a></li>
</ul>
</div>
</li>
</ul>
Not sure if the sub-section within div class="sub" is right. Maybe if I add the selected class to the parent LI though it might work.
I thought for the LI class, I could use the page Name and try something like <li class="{@Name}">
, but had no success with that. Any ideas there would be appreciated too.
Let me know if any more info would be useful.
Many thanks
Upvotes: 0
Views: 1403
Reputation: 4410
You may wish to try the following Umbraco package:
http://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation
You can view the XSLT for it to see how it works or just use it our of the box (I think it will meet your needs).
In terms of your original question, it sounds as if you need some reference information on Umbraco its self.
The best place for that is the Umbraco wiki
Upvotes: 1