Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Apr 26, 2010 @ 17:28
    trfletch
    0

    Pages loading slow because of XSLT menu

    Hi All,

    I have an Umbraco V4 website that has a fly-out menu created using XSLT, the user wanted the menu to go down to 5 levels within the site but with the amount of pages they have it is making the website go slow even if I reduce it down to 4 levels. I have therefore had to reduce it down to 3 levels but I was just wondering if anything can be done to improve the efficiency of my XSLT or is it just the fact that this is going to be a problem having lots of pages and a menu that shows more than 3 levels? This is the XSLT I currently have which is based on the sitemap template:

    <xsl:param name="currentPage"/>
    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="3"/>
    <xsl:template match="/">
    <div id="sitemap">

    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById(1122)"/> 
    </xsl:call-template>

    </div>
    </xsl:template>
    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <ul class="sf-menu"><xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevelForSitemap]">
    <li><xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
      <xsl:attribute name="class">active-menu</xsl:attribute>
      </xsl:if>
    <xsl:choose>
    <xsl:when test="data [@alias = 'nomenulink'] ='1'">
    <a href="#">
    <xsl:value-of select="@nodeName"/></a>
    </xsl:when>
    <xsl:otherwise>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/></a>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="count(./node [string(./data [@alias='nestedmenuHide']) != '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0">  
    <xsl:call-template name="drawNodes">   
    <xsl:with-param name="parent" select="."/>   
    </xsl:call-template> 
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

     

     

  • dandrayne 1138 posts 2262 karma points
    Apr 26, 2010 @ 17:30
    dandrayne
    2

    Hows about enabling caching on the macro?  This should make it very quick, and is enabled through the macro tree in the developer section.  Setting a fairly long cache time should help, and the main navigation is unlikely to change on an gourly basis.

    Dan

  • trfletch 598 posts 604 karma points
    Apr 27, 2010 @ 11:14
    trfletch
    0

    Hi Dan,

    Do I want to enable cache by page or cache personalised? Also what sort of time should I be setting the cache period? Minutes, hours, days?

  • dandrayne 1138 posts 2262 karma points
    Apr 27, 2010 @ 14:50
    dandrayne
    0

    Cache by page I'd say, and if your nav will only be updated every couple of days, I'd cache it for 24 hours.

    You will need to prepare for the call from a client saying "I added a page and it's not showing!"

  • trfletch 598 posts 604 karma points
    Apr 28, 2010 @ 12:36
    trfletch
    0

    Thanks Dan,

    I did try this but it still seemed to be quite slow, the menu is using jquery so I'm wondering if that is something to do with it, I might try disabling it so that it uses just CSS to see if it makes a difference.

Please Sign in or register to post replies

Write your reply to:

Draft