Copied to clipboard

Flag this post as spam?

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


  • Alex Burr 77 posts 128 karma points
    Mar 12, 2010 @ 15:09
    Alex Burr
    0

    Referencing document properties in XSLT

    Hi everyone,

    At my organization we are evaluating Umbraco and the developers are loving it! However I have a question about my XSLT syntax, as I am new to this technology...

    I have created a template and document type that allows for either a two-column (subnav/content) or three-column (subnav/content/sidebar) layout. Basically if the user adds content to the sidebar, then my macro will determine whether to render the third column DIV in the document. I have a similar macro that chooses the appropriate stylesheet (2- or 3-column layout) in the document head.

    I can get the stylesheet to swap correctly, and I can get the sidebar content outputted to the page when applicable, but I am getting the HTML markup printed to the page (the sidebar content is added via Richtext Editor) instead of it being included normally. I believe this is a problem with my XSL syntax.

    In the template I have:

    <asp:content ContentPlaceHolderId="mainContent" runat="server">
        <div id="column1">
            <umbraco:Macro Alias="test_Subnavigation" runat="server" />
        </div>
        <div id="column2">
            <h1><umbraco:Item field="pageName" runat="server"></umbraco:Item></h1>
            <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
        </div>
        <umbraco:Macro Alias="XSL_TextpageThirdColumn" runat="server" />
    </asp:content>

    and in my macro I have:

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
       
        <xsl:choose>
                <xsl:when test="string($currentPage/data[@alias='sidebarText'])!=''">
                <div id="column3">
                    <xsl:value-of select="$currentPage/data[@alias='sidebarText']"/>
                </div>
                </xsl:when>
        </xsl:choose>

    </xsl:template>

    Any help would be great! I'm sure it's something simple.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 12, 2010 @ 15:34
    Chriztian Steinmeier
    0

    Hi Alex,

    Just add the disable-output-escaping attribute to the xsl:value-of instruction:

    <xsl:value-of select="$currentPage/data[@alias='sidebarText']" disable-output-escaping="yes" />

    /Chriztian

  • Alex Burr 77 posts 128 karma points
    Mar 12, 2010 @ 15:39
    Alex Burr
    0

    Glorious! Thank you Chriztian!

Please Sign in or register to post replies

Write your reply to:

Draft