Copied to clipboard

Flag this post as spam?

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


  • Jonas Gunnarsson 44 posts 194 karma points
    Jan 04, 2012 @ 14:11
    Jonas Gunnarsson
    0

    Help with xslt-schema

    Hi,

    I have this blog jonasfotograf.se and I need help with my xslt-schema.

    This is how my tree structure looks like:

    Hem
     - Portfolio
     - Info/Om mig
     - Priser
     - Kontakt
     - Arkiv
     - rss

    And my problem is that I donĀ“t know how to change my xslt to show the Hem-node. 

    xslt-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" exclude-result-prefixes="msxml
    umbraco.library">
        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <!-- update this variable on how deep your navigation should be -->
        <xsl:variable name="maxLevel" select="3"/>
        <xsl:template match="/">
            <ul id="menu">
                <xsl:call-template name="drawNodes">
                    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level=1 and @isDoc]"/>
                </xsl:call-template>
            </ul>
        </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)">
                <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]">
                  
                    <li>
                        <a href="{umbraco.library:NiceUrl(@id)}">
                          <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]) &gt; 0">
                            <xsl:attribute name="class"><xsl:text>no-follow</xsl:text></xsl:attribute>
                        </xsl:if>
                            <xsl:value-of select="@nodeName"/>
                        </a>
                      
                        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]) &gt; 0">
                            <ul>
                                <xsl:call-template name="drawNodes">
                                    <xsl:with-param name="parent" select="."/>
                                </xsl:call-template>
                            </ul>
                        </xsl:if>
                    </li>
                </xsl:for-each>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 04, 2012 @ 14:17
    Tom Fulton
    0

    Hi,

    The problem is you're passing in the "parent" param as your Hem node, so it's starting out by looking for children under the Hem node.

    One way is to manually add the Hem node link in your XSLT file, ex:

            <ul id="menu">
                <li><a href="/">Hem</a></li>
                <xsl:call-template name="drawNodes">
                    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level=1 and @isDoc]"/>
                </xsl:call-template>
            </ul>

    You could also try changing the parent xpath to start at the root "Content" node instead:

                    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::root"/>

    Hope this helps,
    Tom

  • Jonas Gunnarsson 44 posts 194 karma points
    Jan 04, 2012 @ 14:23
    Jonas Gunnarsson
    0

    Hi,

    This solved my problem, many thanks!

    Best regards Jonas

Please Sign in or register to post replies

Write your reply to:

Draft