0
votes

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']) &gt; 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

1
This doesn't resemble a proper question: 1. What is actually asked? 2. The source XML document isn't provided. 3. The wanted result from the transformation isn't provided. 4. No requirements are specified that the transformation should implement.Dimitre Novatchev
1. The code in it's present state doesn't work to display a 2-level menu. My question is can someone help me to make it work. It works for a single menu. 2. What source XML? 3. Good point - now added to main question. 4. I'm not sure what you're looking for here. Thankse-on
e-on: These are questions that everybody trying to understand your post will ask. As a start, people need to have the XML document, the XSLT code and to be able to perform the transformation and repro the reported result. As of now this question is in undefined state.Dimitre Novatchev
Where do I find the XML document? This is my first outing with xslt so apologies if I should know all thise-on
e-on: A transformation is applied on an XML document. If you don't know on what XML document your transformation is applied, then you don't know at all what you are doing, and even you don't know what you have to do.Dimitre Novatchev

1 Answers

1
votes

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