Copied to clipboard

Flag this post as spam?

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


  • Ryan Tomlinson 3 posts 23 karma points
    Jul 27, 2010 @ 13:03
    Ryan Tomlinson
    0

    Creating a treeview navigation

    I'm using jquery treeview to create a help site for our product. I'm using XSLT to render out the navigation menu and letting jQuery.Treeview do the rest.

    I need to render the whole treeview each time (for each page) and obviously highlight the current page. A node in the treeview can either be a link node to that page, or a group node that when selected simply expands down revealing the options.

    For example:

    + Guide
       + Reporting
          - Call Rate
          - Account Visits
       + Messages
          - Inbound
          - Outbound

    Those at the bottom of the tree branch are links. I have created a property in the master document type of 'IsHelpPage' of type true false.

    Unfortunately I can't pick up this property as I look through each page in XSLT. I have the following code:

    <?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="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>


    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="40"/>

    <xsl:template match="/">
    <div id="sitemap">
    <xsl:call-template name="drawNodes">  
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>  
    </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 id="navigation"><xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]">
    <li>
      <xsl:value-of select="./data [@alias = 'IsHelpPage'] = 1"/>
        <xsl:if test="./data [@alias = 'isHelpPage'] != '0'">yes
          <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:if test="$currentPage/@id = current()/@id">
              <xsl:attribute name="class">selected</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="@nodeName"/>data [@alias = 'IsHelpPage']
          </a>
        </xsl:if>

      <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '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>

    Each time the value of the IsHelpPage property is false.

    Any help on this would be greatly appreciated.

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jul 27, 2010 @ 16:03
    Matt Brailsford
    0

    Hi Ryan,

    I would check the casing of your alias, as in your XSLT you have it as both "IsHelpPage" and "isHelpPage". XSLT is case sensitive, so you'll need to make sure the alias you use in your XSLT is exactly the same as that defined on your doc type.

    Matt

  • Ryan Tomlinson 3 posts 23 karma points
    Jul 27, 2010 @ 16:34
    Ryan Tomlinson
    0

    Hi Matt,

    Thanks for the reply. I just left that in as I was trying both cases in case that was my issue. Unfortunately neither work still.

    Ryan

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jul 27, 2010 @ 16:40
    Matt Brailsford
    0

    Ok, just having another look, it seems as though you are using Umbraco 4.5 schema. Is this correct?

    If so, doc type properties are no longer stored on "data" nodes, so rather than

    data [@alias = 'isHelpPage']

    It should now just be

    isHelpPage

    So maybe try switching your if statement to

     <xsl:value-of select="isHelpPage = '1'"/>

    Many thanks

    Matt

  • Ryan Tomlinson 3 posts 23 karma points
    Jul 27, 2010 @ 17:01
    Ryan Tomlinson
    0

    Matt you're a legend. That was exactly the problem. I didn't realise this had changed in the new version.

    Kind regards,

    Ryan

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jul 27, 2010 @ 17:03
    Matt Brailsford
    0

    No problem. Glad you've got it working.

    Many thanks

    Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies