Copied to clipboard

Flag this post as spam?

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


  • Kevin 37 posts 57 karma points
    Apr 29, 2010 @ 06:54
    Kevin
    0

    The "current" class is not applied in the home page

    This starter kit is better than the Runaway one and I like it.

    Just found a small problem:

    In the file \xslt\topNavigation.xslt, the the following bold code seems don't work well:

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

                    <!-- NiceUrl takes a node ID and gives us a 'nice url' to the page -->
                    <a href="{umbraco.library:NiceUrl($homePageNode/@id)}">
                        <xsl:value-of select="$homePageNode/@nodeName" />
                    </a>
                </li>

    When the home page is the current page, the output html should be:
    <li  class="current"><a href="/home.aspx">Home</a></li>

    But the code is aways like this:
    <li><a href="/home.aspx">Home</a></li>

    I hope the user can see what page is the current page, but the home page is not highlighted when the home page is the current page.

  • dandrayne 1138 posts 2262 karma points
    Apr 29, 2010 @ 09:56
    dandrayne
    0

    Hi Kevin

    Thanks for the heads-up.  Here is the updated xslt file.  This package is due a revamp for 4.1, so I'll address this then.

    <?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" 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:template match="/">

    <!--
    Find the homepage (the topmost node in this tree section, with a doctype alias of 'homepage')
    -->
    <xsl:variable name="homePageNode" select="$currentPage/ancestor-or-self::root/node [@nodeTypeAlias='Homepage']" />


    <ul class="nav">
    <!-- we can assume that we'll need a homepage link in this nav -->
    <li>
    <xsl:if test="$homePageNode/@id = $currentPage/@id">
    <xsl:attribute name="class">current</xsl:attribute>
    </xsl:if>
    <!-- NiceUrl takes a node ID and gives us a 'nice url' to the page -->
    <a href="{umbraco.library:NiceUrl($homePageNode/@id)}">
    <xsl:value-of select="$homePageNode/@nodeName" />
    </a>
    </li>

    <!-- this loop takes all of the direct children of the homepage that aren't currently hidden -->
    <xsl:for-each select="$homePageNode/node [string(./data [@alias='umbracoNaviHide']) != '1']">

    <li>
    <!-- a test to set the class of the link to the current page to 'current'

    basically it says: If the current page or one if its parents has a node id equal to the id of the current page,
    set class to current
    -->
    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
    <xsl:attribute name="class">current</xsl:attribute>
    </xsl:if>
    <a href="{umbraco.library:NiceUrl(current()/@id)}">
    <xsl:value-of select="current()/@nodeName" />
    </a>
    </li>

    </xsl:for-each>


    </ul>

    </xsl:template>

    </xsl:stylesheet>

    Dan

     

  • Kevin 37 posts 57 karma points
    May 02, 2010 @ 05:14
    Kevin
    0

    Dan,

    Thanks for your work. The class works well for the Home link now. I think this start kit may have a more general name because this starter kit can be applied to most senarios, not only for business websites. You are the best.

    Kevin

  • Steve Barnhouse 40 posts 63 karma points
    Aug 20, 2010 @ 21:40
    Steve Barnhouse
    0

    Dan,

    I was just about to post a new topic with this same question when I noticed that you answered it here.

    Thanks!

    I agree with Kevin: this is a great starter kit.

    --steve

Please Sign in or register to post replies

Write your reply to:

Draft