Copied to clipboard

Flag this post as spam?

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


  • Jon 10 posts 31 karma points
    Apr 01, 2010 @ 13:23
    Jon
    0

    Don't render empty ul

    What

    Don't render empty ul

    Why

    1. empty ul is invalid (x)html => validating page with w3 validator to fail
    2. CSS set on menu (for ex: different background color/image ) renders "clutter"

    Solution

    Proposed solution:

    surround ul element with conditional

    <xsl:if test="$parentNode/node or $calculatedMednuDepth = 1 and $forceHome">

    <ul>
    ...

     

    Means:

    Only render ul-menu if there are children ;
    with exception if forceHome is selected and it's the 1'st level (the actual home link)

  • Claire Botman 48 posts 77 karma points
    Jan 10, 2011 @ 02:22
    Claire Botman
    1

    It looks like this suggestion was put into the current code, but we still get empty ul if there are docs that have umbracoNaviHide set, so I changed the test to this:

    <xsl:if test="$parentNode/*[@isDoc][string(umbracoNaviHide) != '1'] or ($calculatedMenuDepth = 1 and $forceHome)">
  • Johan 188 posts 380 karma points
    Nov 09, 2011 @ 19:40
    Johan
    0

    Thanks Claire! This should really be included. For me it messed up a lot more than just the semantics. The "isBranch" variable also needs this condition (if you use it). Like this:

    <xsl:variable name="isBranch">
      <xsl:choose>
        <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc][string(umbracoNaviHide) != '1'] and string(count(descendant::umbracoNaviHide[text() = '0'])) != '0'">1</xsl:when>
      </xsl:choose>
    </xsl:variable>
Please Sign in or register to post replies

Write your reply to:

Draft