Copied to clipboard

Flag this post as spam?

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


  • Olly Berry 47 posts 68 karma points
    Oct 20, 2009 @ 12:22
    Olly Berry
    0

    umbracoNaviHide problem - nodes do not reappear when unchecked

    Hello,

    I have a problem which has me tearing my hair out! I am using an XSLT macro to generate a navigation menu which seemed to be working fine until now:

    <?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"
    exclude-result-prefixes="msxml umbraco.library">

    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>
    <xsl:param name="maxDeep" select="99"/>
    <!-- Input the documenttype you want here -->
    <xsl:variable name="documentTypeAlias" select="string('Category Home Page')"/>
    <!-- Change this to root menu node - ie Home -->
    <xsl:variable name="source" select="1046"/>

    <xsl:template match="/">

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

    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <xsl:param name="startLevel" select="$parent/@level" />

    <xsl:choose>

    <xsl:when test="($parent/@level - $startLevel) = 0">

    <div id="smoothmenu1" class="ddsmoothmenu">
    <ul id="toplevel">
    <xsl:for-each select="$parent/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}" class="topitem">
    <xsl:element name="img">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(./data [@alias='menuImage'], 'false')/data [@alias = 'umbracoFile']"/>
    </xsl:attribute>
    <xsl:attribute name="onmouseover">
    this.src="<xsl:value-of select="umbraco.library:GetMedia(./data [@alias='menuImageHover'], 'false')/data [@alias = 'umbracoFile']"/>"
    </xsl:attribute>
    <xsl:attribute name="onmouseout">
    this.src="<xsl:value-of select="umbraco.library:GetMedia(./data [@alias='menuImage'], 'false')/data [@alias = 'umbracoFile']"/>"
    </xsl:attribute>
    </xsl:element>
    </a>

    <!-- recursive calling of same template for childs -->
    <xsl:if test="count(./descendant::node) > 0 and (./@level - $startLevel) &lt; $maxDeep">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="."/>
    <xsl:with-param name="startLevel" select="$startLevel"/>
    </xsl:call-template>
    </xsl:if>
    </li>

    </xsl:for-each>
    </ul>

    </div>

    </xsl:when>

    <xsl:otherwise>
    <ul class="submenu">
    <xsl:for-each select="$parent/node">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}" class="subitem">
    <xsl:if test="position() != last()">
    <xsl:attribute name="style">border-bottom:1px solid #ccc;</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@nodeName"/>
    </a>

    <!-- recursive calling of same template for childs -->
    <xsl:if test="count(./descendant::node) > 0 and (./@level - $startLevel) &lt; $maxDeep">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="."/>
    <xsl:with-param name="startLevel" select="$startLevel"/>
    </xsl:call-template>
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>

    </xsl:otherwise>

    </xsl:choose>

    </xsl:template>

    </xsl:stylesheet>

    I tested that this worked by checking the Hide Page? (umbracoNaviHide) checkbox on a few of the nodes and they duly did not appear in the menu. Good. The problem then, is that after unchecking the box for these nodes, they do not reappear in the menu!! I have cleared caches and republished the entire site. I have even deleted the nodes and recreated them with the same result. I have also deleted and recreated the macro. When I check the umbraco.config file, the nodes that are not appearing DO NOT have a value for umbracoNaviHide:

            <data alias="metaDescription"><![CDATA[]]></data>
    <data alias="metaKeywords"><![CDATA[]]></data>
    <data alias="contentStrapline"><![CDATA[]]></data>
    <data alias="bodyText"><![CDATA[]]></data>
    <data alias="umbracoNaviHide">
    </data>

    What can I do to resolve this? Please help.

    I am using umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)

    Many thanks,


    Olly

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Oct 20, 2009 @ 12:38
    Rasmus Berntsen
    0

    Try to use the "Save and publish" button on each specific node, eventhough your umbraco.config looks fine... Hmnn... You could also, for testing purpose, try to set the "data [@alias='umbracoNaviHide']) != '1'" to 0. That way you'll know if Umbraco reads it as a 1 or nothing.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Oct 20, 2009 @ 12:44
    Peter Dijksterhuis
    0

    Try to delete the umbraco.config and republish the site. That should cause the umbraco.confog-file to be recreated. Check if it actually IS recreated. If not, you have a permission-problem. If it is, check the file and see if the values now are there.

    HTH,

    PeterD

  • Olly Berry 47 posts 68 karma points
    Oct 20, 2009 @ 13:04
    Olly Berry
    0

    Ok, this gets stranger...

    I have "Save and Publish"ed every node in the site - now when I view umbraco.config, every node has:

    <data alias="umbracoNaviHide">0</data>

    However, now my menu has disappeared entirely!!

    I have tried setting the 1 to a 0 as you suggested,  - no menu (as I would expect).

    However after changing it back to a 1 my menu has disappeared entirely!!

    I am really struggling to understand this.

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Oct 20, 2009 @ 13:16
    Rasmus Berntsen
    0

    Alright. First problem solved. And now a new one. :)

    What if you test your xslt in Umbraco Developer section? With the "Visualize XSLT" function... Still no good? Sounds a bit odd, indeed.

  • Olly Berry 47 posts 68 karma points
    Oct 20, 2009 @ 13:30
    Olly Berry
    0

    OK fixed. For some reason (I have no idea why?) when I republished, the documentTypeAlias had changed in umbraco.config - I have adjusted the xslt accordingly and it's all good now.

    Thanks for your help guys : )

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Oct 20, 2009 @ 13:32
    Rasmus Berntsen
    0

    Hehe, jup... That's a classic too. :)

Please Sign in or register to post replies

Write your reply to:

Draft