Menu Help Options
Skiltz
Posted: Saturday, December 15, 2007 5:22:08 AM

Rank: Devotee

Joined: 12/6/2007
Posts: 61
Okay I am struggling with XSTL :(

http://www.catsanddogs.co.nz/dogs.aspx - I have this menu which works fine, but if i click on a 3rd level menu then I want it to expand into the main menu also, only works for second level menus at the moment..becuase a UL tag has been created. If anyone could help me with this it would be much appreciated.


Code:

<?xml version="1.0" encoding="utf-8"?>
<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:variable name="currentID" select="$currentPage/self::node/@id"/>
  <xsl:output method="html"/>
  <xsl:param name="currentPage"/>
  <xsl:variable name="maxLevelForSitemap" select="6"/>


  <xsl:template match="/">
    <ul class="menulist" id="listMenuRoot">
      <xsl:call-template name="drawNodes">
        <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1 and string(data [@alias='umbracoNaviHide']) != '1']  "/>
      </xsl:call-template>
    </ul>
  </xsl:template>
 
  <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <xsl:for-each select="$parent/node [string(data [@alias='umbracoNaviHide']) != '1']">
     
        <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
         <xsl:if test="current()/@id = $currentID">
             <xsl:attribute name="style">background-color: green;</xsl:attribute>
          </xsl:if>
          <xsl:if test="current()/parent::node/@id = $currentID">
            <xsl:attribute name="style">background-color: #a13d55;</xsl:attribute>
          </xsl:if>
          <xsl:value-of select="@nodeName"/>
        </a>

<xsl:if test="count(node[string(./data [@alias='umbracoNaviHide']) != '1' ]) &gt; 0">
          <xsl:if test="current()/@id != $currentID">
   
            <ul>
              <xsl:call-template name="drawNodes">
                <xsl:with-param name="parent" select="."/>
              </xsl:call-template>
            </ul>
          </xsl:if>
        </xsl:if>

      </li>
      <xsl:if test="current()/@id = $currentID">
        <xsl:call-template name="drawNodes">
          <xsl:with-param name="parent" select="."/>
        </xsl:call-template>
      </xsl:if>
    </xsl:for-each>
    </xsl:template>
    
    
</xsl:stylesheet>


New Zealand Umbracoee
neehouse
Posted: Saturday, December 15, 2007 7:23:55 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,074
Location: Charleston, West Virginia, United States
Change the test in line 49 to be count($currentPage/ancestor-or-self::node[@id = current()/@id]) &gt; 0

This will allow it to expand all parent levels in the section...

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.