Recursive Navigation Menu for Umbraco 4.5

I recently migrated a site from Umbraco 4.0.2 to Umbraco 4.5 and moved to the new XML schema.

Lots of my XSLT automagically converted using the XsltUpdater for Umbraco package but not everything.

So here’s my updated Recursive Navigation Menu XSLT for the new Umbraco 4.5 XML schema :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<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="/">
 
    <xsl:call-template name="menu">
      <xsl:with-param name="level" select="1"/>
    </xsl:call-template>
  </xsl:template>
 
<xsl:template name="menu">
    <xsl:param name="level"/>
 
    <xsl:if test="count($currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1'] ) &gt; '0'">
          <ul id="level{$level}">
              <xsl:if test="$level=1">
            <li>
              <a href="/" id="nav-home">Home</a>
            </li>
          </xsl:if>
 
          <xsl:for-each select="$currentPage/ancestor-or-self::*  [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1'] ">
            <li>
              <xsl:if test="$currentPage/@id = current()/@id">
                <xsl:attribute name="class">selected</xsl:attribute>
              </xsl:if>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
                  <xsl:attribute name="class">selected</xsl:attribute>
                </xsl:if>
                <xsl:if test="$level = 1">
                  <xsl:attribute name="id">nav-<xsl:value-of select="./umbracoUrlName"/></xsl:attribute>
                </xsl:if>
                <xsl:value-of select="@nodeName"/>
              </a>
                <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
                    <xsl:call-template name="menu">
                      <xsl:with-param name="level" select="$level+1"/>
                    </xsl:call-template>
                </xsl:if>
            </li>
          </xsl:for-each>
        </ul>    
     </xsl:if>
 
</xsl:template>
</xsl:stylesheet>

In my case I also exclude pages of a certain docType, in this case Job, using [name()!='Job'] which is the equivalent of [@nodeTypeAlias!='Job'] in the old schema. So, you can do things like :

1
<xsl:if test="count($currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1'] [name()!='Job']) &gt; '0'">

instead of

1
<xsl:if test="count($currentPage/ancestor-or-self::node [@level=$level]/node [@nodeTypeAlias!='Job'] [string(data [@alias='umbracoNaviHide']) != '1']) &gt; '0'">

or

1
2
<xsl:for-each select="$currentPage/*[not(self::NewsItem)]">
</xsl:for-each>

instead of

1
2
<xsl:for-each select="$currentPage/node [@nodeTypeAlias!='NewsItem']">
</xsl:for-each>

Credit to Lordtoro for an example that helped me convert my old XSLT Recursive Navigation.

Posted in .NET, umbraco | Leave a comment

Tauranga Web Meetup

Tauranga Web Meetups are go!

I’ve been wanting a Tauranga Web Meetup since I moved here almost 4 years ago.

There’s a lot of web professionals based in Tauranga, Mount Maunganui and Papamoa but I haven’t met many of them in person. Twitter’s great and I’ve been following what a few of the locals are up to, but nothing beats getting together in the same room picking brains.

So finally we have a Tauranga Web Meetup happening. The first meetup is at QJumpers, above Storage Solutions, Bay Central, Tauranga (by Briscoes, Rebel Sport etc).

View Larger Map

The Auckland Web Meetups have been going strong for a few years now and are the inspiration for the Tauranga Web Meetup. Hopefully we can get it happening in Tauranga. I look forward to meeting local web professionals and finding out who is out there. There’s a lot of work I’d like to farm out to the appropriately skilled people and I’m sure there’s lots of other locals thinking the same.

Let’s get together.

Posted in Tauranga, web | Leave a comment

Cults – Go Outside

<a href="http://cults.bandcamp.com/album/cults-7">Go Outside by Cults</a>

Posted in drift | Tagged | Leave a comment

Augmented-reality maps

Posted in drift | Tagged , , | Leave a comment

Brian Jonestown Massacre – Dekta

DETKA! DETKA! DETKA! From the new Brian Jonestown Massacre album Who Killed Sgt Pepper?

Posted in Music | Tagged | Leave a comment

The Knife – Tomorrow in a Year

Posted in Music | Tagged | Leave a comment

The High Road – Broken Bells

The new vid for Broken Bells The High Road.
Broken Bells = The Shins’ James Mercer and Dangermouse.

The High Road

Broken Bells 

Posted in Music | Tagged | Leave a comment

Banksy – Exit Through The Gift Shop trailer

Posted in movies | Tagged , , | Leave a comment

The XX – VCRs

Posted in Music | Tagged | Leave a comment

Atlas Sound – Attic Lights

Atlas Sound – “Attic Lights” – A Take Away Show from La Blogotheque on Vimeo.

Posted in Music | Tagged | Leave a comment