Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shaun ak 2 posts 22 karma points
    Sep 07, 2010 @ 11:37
    Shaun ak
    0

    Styling root navigation using Xslt

    Hi

    This is my first post, and would like to get some advise on how to style the rootnode with a css class when selected.  I am new to Xslt, so not 100% sure if I am going about this the right way?

    All code using $currentPage when selected work fine it is just the $rootNode code (highlight in bold)

     

    <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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
      
       <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::* [@level = $level]"/>


    <ul>
      
       <li>
         <xsl:if test="$rootNode/ancestor-or-self::*/@id = current()/@id">
           <xsl:attribute name="class">current</xsl:attribute>
         </xsl:if>

          <a href="{umbraco.library:NiceUrl($rootNode/@id)}">
            <xsl:value-of select="$rootNode/@nodeName"/>
          </a>
       </li>



    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
          <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
            <!-- we're under the item - you can do your own styling here -->
            <xsl:attribute name="class">current</xsl:attribute>
          </xsl:if>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

     

    Any help/ advise would be much appreciated!

  • Shaun ak 2 posts 22 karma points
    Sep 07, 2010 @ 11:50
    Shaun ak
    0

    Hi All

     

    I actually solved my own problem by looking at some of the over posts on this forum!

    The code in bold is what I replaced:

       <li>
         <xsl:if test="$currentPage/@level = 1">
           <xsl:attribute name="class">current</xsl:attribute>
         </xsl:if>

          <a href="{umbraco.library:NiceUrl($rootNode/@id)}">
            <xsl:value-of select="$rootNode/@nodeName"/>
          </a>
       </li>

    All is fine now and really enjoying the Umbraco enviroment!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies