Copied to clipboard

Flag this post as spam?

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


  • Tom Allen 50 posts 71 karma points
    Sep 13, 2011 @ 13:48
    Tom Allen
    0

    Help needed

    I've just begun building a site in Umbraco after using .NET for many years.

    I'm trying to accomplish something which I am sure should be very simple.

    This is to display a menu in the footer of my site, displaying a list of page links to pages which are children of a 'Footer' placeholder page which is not displayed in the main menu.

    I published some dummy pages in the hierarchy Homepage > Footer > Test Page 1, etc.

    Then I created a macro and an XSLT file to display a list of the pages at this location in the hierarchy.

    In my master page:

    <umbraco:macro alias="umbFooterNavigation" startNodeId="1099" runat="server"></umbraco:macro>

    1099 is the ID of the placeholder page.

    In the macro's XSLT file:

    <?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:variable name="startNodeId" select="/macro/startNodeId"/>
    <xsl:template match="/">
        <ul>
            <xsl:for-each select="umbraco.library:GetXmlNodeById($startNodeId)/node">
                <li>
                    <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"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>
    </xsl:stylesheet>

    But the output renders nothing more than an empty self-closing <ul /> tag, which breaks my page rendering.

    Any ideas to help out a newbie? And how can I view the raw XML output of an XSLT file?

    Thanks in advance!

  • Tom Allen 50 posts 71 karma points
    Sep 13, 2011 @ 13:53
    Tom Allen
    0

    I originally tried this code, with the same result:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="startNodeId" select="/macro/startNodeId"/>
      <xsl:template match="/">
        <ul>
            <xsl:for-each select="$currentPage/ancestor-or-self::* [@id=$startNodeId]/*">
                <li>
                    <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"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
     </xsl:template>

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 13, 2011 @ 13:53
    Chriztian Steinmeier
    0

    Hi Tom - welcome to Umbraco :-)

    The snippet you've got uses what's referred to as "the legacy XML schema" - change this:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($startNodeId)/node">

    to this:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($startNodeId)/*[@isDoc]">

    To start getting your documents rendered.

    Then search the forum for info about the new XML schema.

    /Chriztian

  • Tom Allen 50 posts 71 karma points
    Sep 13, 2011 @ 14:12
    Tom Allen
    0

    Legend - how many hours did I spend on that?!? Thanks a million. Looking up the new schema now...

    Tom

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 13, 2011 @ 14:58
    Chriztian Steinmeier
    0

    No worries - it's pure joy from now on :-) (Famous last words...)

    BTW: Regarding the XML output - do yourself a favor and install XMLDump right away (In Developer/Packages > Developer Tools) - it'll help you tons!

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft