Copied to clipboard

Flag this post as spam?

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


  • Alex 10 posts 30 karma points
    May 26, 2011 @ 02:14
    Alex
    0

    xslt @level behaviour in 4.7 varies between browsers

    Hi 

    we have ported one of our site from 4.6 to 4.7 however we have found an issue with an xslt that is using the @level property in its logic. 

     

    Basically what happens is that IE is reading it correctly the node level however Firefox is reading each item on the first level as its own level 

    Example

    • lv1 - About
    • lv2- Details
    • lv2 - Test
    • lv1 - Products
    • lv1 - Member Deals
    In IE it would see the about , products and member deals as level 1 , however Firefox would read them as 1,2 and 3 respectively
    Regards
    Alex

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 26, 2011 @ 04:41
    Tom Fulton
    1

    Hi Alex,

    The @level attribute of a node should have nothing to do with a browser, it's stored in the XML.  Are you sure the actual @level value is different, or are you just seeing incorrect menu indentations?  I would guess there is some type of markup issue (an unclosed or blank ul/li getting self closed, or something similar).  Perhaps you could post your XSLT?

    -Tom

  • Alex 10 posts 30 karma points
    Jun 22, 2011 @ 02:01
    Alex
    0

    Hi 

     

    Sorry for delay , the code below is what we were doing however we found the<xsl:if test="@level &gt;= $minLevel and (@level &lt;= $maxLevel) and string(umbracoNaviHide) = '0' "> statement was redundant  in the <xsl:template match="*[@isDoc]"> template ,  so simply ended up removing that and then it behaved correctly however there was a definite difference in behaviour between the different browsers that was not the case with the code in earlier versions.


     

    <xsl:template match="/">

     

        <!-- Main UL -->

        <ul>

          <xsl:attribute name="id">

            <xsl:value-of select="$ulMainId"/>

          </xsl:attribute>

     

          <!-- consider all the children of the ancestor on (minLevel - 1) -->

          <xsl:apply-templates select="$currentPage/ancestor-or-self::*[@isDoc] [@level=($minLevel -1)]/*[@isDoc] [string(umbracoNaviHide) = '0']" />

     

        </ul>

     

      </xsl:template>

     

     

     

      <xsl:template match="*[@isDoc]">

     

        <xsl:if test="@level &gt;= $minLevel and (@level &lt;= $maxLevel) and string(umbracoNaviHide) = '0' ">

            <li>

     

              <!-- active on first level -->

              <xsl:if test="(@level = $minLevel) and ($currentPage/@id = current()/@id)">

                <xsl:attribute name="id">

                  <xsl:value-of select="$liActiveId"/>

                </xsl:attribute>

              </xsl:if>

     

     

              <!-- URL -->

              <a href="{umbraco.library:NiceUrl(@id)}">

                <!-- active on inner levels -->

                 <xsl:if test="$currentPage/@id = current()/@id and (@level > $minLevel)">

                  <xsl:attribute name="class">

                    <xsl:value-of select="$linkActiveClass"/>

                  </xsl:attribute>

                </xsl:if>

     

                <xsl:choose>

                  <xsl:when test="string-length(NavTitle) > 0">

                  <xsl:value-of select="NavTitle"/>

                  </xsl:when>

                  <xsl:otherwise>

                    <xsl:value-of select="Title"/>

                  </xsl:otherwise>

                </xsl:choose>

              </a>

     

              <!-- has visible children -->

              <xsl:if test="(count(*[@isDoc][string(umbracoNaviHide) = '0']) > 0)">

                <ul>

     

                  <xsl:attribute name="class">

                    <xsl:value-of select="$ulSubClass"/>

                  </xsl:attribute>

     

                  <!-- reapply the template -->

                  <xsl:apply-templates select="*[@isDoc]"/>

                </ul>

     

              </xsl:if>

            </li>

     

          </xsl:if>

      </xsl:template>

     

     

    </xsl:stylesheet>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 22, 2011 @ 13:22
    Tom Fulton
    0

    Hi - I would guess that with that line in place an empty <ul></ul> was getting written out somewhere which can behave different on different browsers.  Anyway, glad you got it sorted!

  • Alex 10 posts 30 karma points
    Jun 23, 2011 @ 03:10
    Alex
    0

    Yeah probably something like that , thanks for the help

Please Sign in or register to post replies

Write your reply to:

Draft