Copied to clipboard

Flag this post as spam?

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


  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Nov 03, 2011 @ 14:33
    Bjarne Fyrstenborg
    0

    XSLT menu not giving output

    Hi..

    I have a XSLT menu on this site http://sub.ak-security.dk/da/forside.aspx which is the ones used in the Tea Commerce v2 starter kit too: http://starterkit.teacommerce.dk

    The site is hosted by Surftown, but somehow in doesn't seem the render any output, on at couple of sites at UnoEuro:

    http://onetake.dk.nt13.unoeuro-server.com/
    http://xn--thyregod-vandvrk-7ob.dk.nt5.unoeuro-server.com/

    The last link have I tried with to diffent menus: the one I first mentioned which not gives me any output and the standard XSLT menu from a template in Umbraco (list subpages from current page), where it's placed in the mastertemplate, but somehow it isn't shown on the subpages. Both homepages and subpages inherit from masterpage, so the only difference is the text "Forside" and "Tekstsider" ..

    Is there something that might prevent the xslt from rendering?

    Bjarne

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 03, 2011 @ 22:40
    Jan Skovgaard
    0

    Hi Bjarne

    What does the xslt in question look like? And is the content structure of both sites indentical in Umbraco?

    If you just write some text in a xslt file and drop it on the template where you want the menu to render...does that display?

    If so...have you checked if the site is setup to be using the old XML schema before v4.5?

    /Jan

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Nov 03, 2011 @ 23:06
    Bjarne Fyrstenborg
    0

    Hi Jan..

    Well the content structure isn't teh same, but it shouldn't be a problem, as the macro has some parameters referering to the level in the structure..
    yes I tried to write some text and it's displayed... I have created a simple master page and some content place for homepage and textpages.. and when I just entering some text in the template it is diplayed .. but not any of the menu as an unordnered list..

    The xslt looks like this:

    <?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="html" omit-xml-declaration="yes"/>
        
    <!--
        WHAT IS THIS FILE?
        The almighty navigation xslt.
        Will write a simple ul li menu with all
        the classes needed to style it in every possible way.
        Settings include:
        - imageProperty (For background images)
        - sort (descending/ascending)
        - ignoreDocumentTypes (Commalist of doc type aliases to ignore/leave out)
        - rootNodeId (Specifc node as root instead of the currentPage)
        - fromLevel (Index of level to start on. Relative to the content root)
        - toLevel (Index of level to end on. Relative to the content root)
        - showOnlyCurrentPath (Set 1 or 0. )
        - isSitemap (Will help sort out all nodes that should be hidden from the sitemap)
    -->

    <xsl:param name="currentPage"/>
        
    <xsl:variable name="Navigation.imageProperty" select="/macro/imageProperty" />
    <xsl:variable name="Navigation.sort">
      <xsl:choose>
        <xsl:when test="/macro/sort != ''">
          <xsl:value-of select="/macro/sort" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>ascending</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
        
    <xsl:variable name="Navigation.ignoreDocumentTypes" select="/macro/ignoreDocumentTypes"/>
       
    <xsl:variable name="Navigation.rootNodeId">
      <xsl:choose>
        <xsl:when test="/macro/rootPage != ''">
        <xsl:value-of select="/macro/rootPage" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$currentPage/@id" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="Navigation.rootNode" select="umbraco.library:GetXmlNodeById($Navigation.rootNodeId)"/>
        
    <xsl:variable name="Navigation.fromLevel">
      <xsl:choose>
        <xsl:when test="string(/macro/useSelfAsRoot) = '1'">
          <xsl:value-of select="number($Navigation.rootNode/@level) + 1" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="/macro/fromLevel != ''">
              <xsl:value-of select="/macro/fromLevel" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="2" />
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="Navigation.toLevel">
      <xsl:choose>
        <xsl:when test="/macro/numberOfLevels != ''">
          <xsl:value-of select="number($Navigation.fromLevel) + number(/macro/numberOfLevels) - 1" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="1000" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
        
    <xsl:variable name="Navigation.showOnlyCurrentPath">
      <xsl:choose>
        <xsl:when test="/macro/showOnlyCurrentPath != ''">
          <xsl:value-of select="/macro/showOnlyCurrentPath" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="1" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
        
    <xsl:variable name="Navigation.isSitemap">
      <xsl:choose>
        <xsl:when test="/macro/isSitemap != ''">
          <xsl:value-of select="/macro/isSitemap " />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="0" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>


    <xsl:template match="/">
      
      <xsl:call-template name="MenuItems">
        <xsl:with-param name="menuItems" select="$Navigation.rootNode/ancestor-or-self::* [@level=number($Navigation.fromLevel - 1)]/* [@isDoc and not(contains($Navigation.ignoreDocumentTypes, name())) and ( ( $Navigation.isSitemap != '1' and string(./umbracoNaviHide) = '0' ) or ( $Navigation.isSitemap = '1' and string(./umbracoSitemapHide) = '0' ) )]" />
        <xsl:with-param name="currentLevel" select="$Navigation.fromLevel" />
        <xsl:with-param name="levelCounter" select="1" />
      </xsl:call-template>

    </xsl:template>
        
    <xsl:template name="MenuItems">
      <xsl:param name="menuItems"/>
      <xsl:param name="currentLevel"/>
      <xsl:param name="levelCounter"/>
      
      <xsl:variable name="count" select="count($menuItems)"/>
      
      <xsl:if test="$count &gt; 0">
        
        <ul>
          <xsl:if test="$levelCounter = 1 and /macro/navigationId">
            <xsl:attribute name="id"><xsl:value-of select="/macro/navigationId"/></xsl:attribute>
          </xsl:if>
          <xsl:attribute name="class"><xsl:value-of select="concat('lvl', $levelCounter)"/></xsl:attribute>
          
          <xsl:for-each select="$menuItems">
            <xsl:sort select="@sortOrder" order="{$Navigation.sort}" data-type="number"/>
                  
            <xsl:if test="umbraco.library:HasAccess(@id, @path)">
              

              <xsl:variable name="childMenuItems" select="./* [@isDoc and not(contains($Navigation.ignoreDocumentTypes, name())) and ( ( $Navigation.isSitemap != '1' and ( string(./umbracoNaviHide) = '0' or string(./umbracoNaviHide) = '0' ) ) or ( $Navigation.isSitemap = '1' and (string(./umbracoSitemapHide) = '0' or string(./umbracoSitemapHide) = '' ) ) )]"/>
              <xsl:variable name="active" select="$currentPage [@isDoc]/@id=@id"/>
              <xsl:variable name="inpath" select="$currentPage/ancestor-or-self::* [@isDoc]/@id=@id"/>
              <xsl:variable name="firstitem" select="position() = 1"/>
              <xsl:variable name="lastitem" select="position() = $count"/>
              <xsl:variable name="hasChildren" select="count($childMenuItems) &gt; 0"/>
              <xsl:variable name="childrenShown" select="count($childMenuItems) &gt; 0 and number($currentLevel) &lt; number($Navigation.toLevel) and ( ( $inpath = '1' and string($Navigation.showOnlyCurrentPath) != '0' ) or string($Navigation.showOnlyCurrentPath) = '0' )" />

              <xsl:variable name="className">
                <xsl:value-of select="concat('lvl', $levelCounter)"/>
                <xsl:value-of select="concat(' pos', position())"/>
                <xsl:if test="$active = '1'"active</xsl:if>
                <xsl:if test="$inpath = '1'"inpath</xsl:if>
                <xsl:if test="$firstitem = '1'"firstitem</xsl:if>
                <xsl:if test="$lastitem = '1'"lastitem</xsl:if>
                <xsl:if test="$hasChildren = '1'"><xsl:texthasChildren</xsl:text></xsl:if>
                <xsl:if test="$childrenShown = '1'"><xsl:textchildrenShown</xsl:text></xsl:if>
              </xsl:variable>
              
              <li>
                <xsl:if test="$className != ''"><xsl:attribute name="class"><xsl:value-of select="$className" /></xsl:attribute></xsl:if>
                
                <title="{@nodeName}">
                  <xsl:if test="$className != ''"><xsl:attribute name="class"><xsl:value-of select="$className" /></xsl:attribute></xsl:if>
                  <xsl:attribute name="href">
                    <xsl:choose>
                      <xsl:when test="local-name() != 'ExternalLink'">
                        <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="./externalURL" />
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:attribute>
                  <xsl:if test="$Navigation.imageProperty != ''">
                    <xsl:attribute name="style">
                      <xsl:text>background-image:url(</xsl:text><xsl:value-of select="umbraco.library:GetMedia(* [$Navigation.imageProperty = name()], 0)/umbracoFile" /><xsl:text>);</xsl:text>
                    </xsl:attribute>
                   </xsl:if>
                   <span><xsl:value-of select="@nodeName" /></span>
                </a>

                <xsl:if test="number($currentLevel) &lt; number($Navigation.toLevel) and ( ( $inpath = '1' and string($Navigation.showOnlyCurrentPath) != '0' ) or string($Navigation.showOnlyCurrentPath) = '0' )">
                  <xsl:call-template name="MenuItems">
                    <xsl:with-param name="menuItems" select="$childMenuItems" />
                    <xsl:with-param name="currentLevel" select="$currentLevel+1" />
                    <xsl:with-param name="levelCounter" select="$levelCounter+1" />
                  </xsl:call-template>
                </xsl:if>
              </li>
            </xsl:if>
          </xsl:for-each>
          
        </ul>
      </xsl:if>
      
    </xsl:template>

    </xsl:stylesheet>

    and then I have in the master template: <umbraco:Macro fromLevel="2" numberOfLevels="1" showOnlyCurrentPath="1" useSelfAsRoot="0" isSitemap="0" navigationId="topnav" rootPage="" ignoreDocumentTypes="" imageProperty="" sort="ascending" Alias="Navigation" runat="server" />

    It's working fine on Surftown, but it dosn't seem to give any output... when I use the template (list subpages from current page) in Umbraco an place it on master page, it isn't shown on the content pages (homepage, textpage..)

    I tried to install a Website Starter Package and it seems to render that xslt menu: http://onetake.dk.nt13.unoeuro-server.com/products/

    It's v.4.7 and I haven't changes the xml schema.. so I think it's the new one as it should be from v.4.5 and up...

    Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft