Copied to clipboard

Flag this post as spam?

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


  • Rory 59 posts 84 karma points
    Jul 18, 2011 @ 19:18
    Rory
    0

    umbracoNaviHide not working

    Hi all

    I'm trying to build a recursive menu based on a modification to the recursive menu xslt snippet on this site. It seems to work ok, apart from it's displaying nodes which should be hidden in the navigation. It looks like the umbracoNaviHide is not working.

    When I use one of the other navigation xslt macros, it works fine. I've cut and pasted the relevant line from another xslt file and it still doesn't work in the recursive one.

    Here is my code:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
    <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:param name="level" select="1"/>
    <xsl:variable name="stopLevel" select="/macro/maxDepth"/>
    <xsl:variable name="mystartNodeId" select="/macro/startNodeId"/>
    <xsl:variable name="cssClass" select="/macro/NavigationCSSClass"/>
    <xsl:variable name="cssID" select="/macro/NavigationCSSId"/>
    <xsl:variable name="boolImageLink" select="/macro/navImageLink"/>
    <xsl:variable name="IDSelectorPrefix" select="/macro/IDPrefix"/>
    <xsl:variable name="disableNav" select="/macro/disableNav"/>
    <xsl:template match="/">
     <xsl:call-template name="menu">
      <xsl:with-param name="level" select="$level"/>
     </xsl:call-template>
    </xsl:template>
    <xsl:template name="menu">
     <xsl:param name="level" />
      <ul class="menu2"> 
      <xsl:if test="count($currentPage/ancestor::root/* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; '0'">
       <xsl:for-each select="$currentPage/ancestor::root/* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
        <li class="top">
         <a href="{umbraco.library:NiceUrl(@id)}" class="top_link">
          <span>
           <xsl:if test="$currentPage/@id = current()/@id">
            <xsl:attribute name="class">down</xsl:attribute>
           </xsl:if>
           <xsl:value-of select="@nodeName"/>
          </span>
         </a>
         <xsl:if test="count(current()/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; '0'">
          <xsl:call-template name="submenu">
           <xsl:with-param name="level" select="$level+1"/>
          </xsl:call-template>
         </xsl:if>
        </li>
       </xsl:for-each>
      </xsl:if>
     </ul>
    </xsl:template>
    <xsl:template name="submenu">
     <xsl:param name="level"/>
      <ul class="sub">
       <xsl:for-each select="current()/* [@isDoc and string(umbracoNaviHide) != '1']">
        <li>
         <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:if test="count(current()/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; '0'">
           <xsl:attribute name="class">fly</xsl:attribute>
          </xsl:if>
          <xsl:value-of select="@nodeName"/>
         </a>
         <xsl:if test="count(current()/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; '0'">
          <xsl:call-template name="submenu">
           <xsl:with-param name="level" select="$level+1"/>
          </xsl:call-template>
         </xsl:if>
        </li>
       </xsl:for-each>
      </ul>
     </xsl:template>
    </xsl:stylesheet>
     

    hope someone can spot what will probably turn out to be a obvious mistake! I've been staring at it too long to see the wood from the trees, and I'm a newbie at xslt too, which doesn't help.

    cheers

    Rory

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 18, 2011 @ 20:15
    Fuji Kusaka
    0

    Double check your document type filed if you have havent done any typying error in your alias for the umbracoNaviHide.

     

     

  • Rory 59 posts 84 karma points
    Jul 18, 2011 @ 20:24
    Rory
    0

    Hi Fuji,

    could you please explain what you mean? I've not edited any of the Generic Properties for any of my standard document types, if that's what you mean?

    cheers

    Rory

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 18, 2011 @ 20:29
    Fuji Kusaka
    0

    Hi Roy,

    You need to create a field under which you will name the Alias as umbracoNaviHide, and choose the True/False (type). Then straight forward choose any of the content node you want to hide from your navigation and check it.

     

    //fuji

  • Rory 59 posts 84 karma points
    Jul 18, 2011 @ 22:10
    Rory
    0

    Hi Fuji

    yes, I already have a field in Generic Properties which has the alias umbracoNaviHide (true/false). Some of my pages are set to True, but these are still showing when I use the XSLT listed above.

    When I use a different XSLT such as the umbTopNavigation.xslt it works fine, and doesn't show the hidden nodes. This is why I'm confused where the problem is.

    Rory

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 18, 2011 @ 22:40
    Fuji Kusaka
    0

    Rory am not sure but can you try removing

     

      <xsl:iftest="count($currentPage/ancestor::root/* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; '0'">

    to

      <xsl:iftest="count($currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">

     

Please Sign in or register to post replies

Write your reply to:

Draft