Copied to clipboard

Flag this post as spam?

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


  • shruti 21 posts 42 karma points
    Feb 05, 2010 @ 04:18
    shruti
    0

    XSLT RenderMacroContent

    Could anyone give me XSLT example using RenderMacroContent , which renders macro contents added in umbraco rich text edior. I am trying with macro "CWS_Navi" from CWS starter kit as : 

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;CWS_Navi&quot; runat=&quot;server&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes"/>

    But it is showing me blank string.

    Please advice.

    Thanks!

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 05, 2010 @ 08:20
    Lee Kelleher
    2

    Hi shruti,

    To me, it looks like you are calling RenderMacroContent correctly. It shouldn't make a difference, but try removing the "runat=server" attribute from the macro string.

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;CWS_Navi&quot; &gt;&lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes" />

    What is the underlying control of the macro? .NET user-control (ASCX) or an XSLT?

    If it's a .NET user-control, then it's a no-go!  The rendering of XSLT happens to far into the ASP.NET Page Life-cycle to load-in. (sorry)

    Good luck, Lee.

  • shruti 21 posts 42 karma points
    Feb 05, 2010 @ 16:18
    shruti
    0

    I tried without server tag and still giving me blank string . This is not a .NET control .

    Its an XSLT macro from CWS starter kit , named : [XSLT] Navi . And i am adding this macro to my page using RTE , and want to render its ouput using XSLT.could you provide the XSLT to display any XSLT macro? can pick any XSLT macro from CQS starter site.

    Thanks,

  • shruti 21 posts 42 karma points
    Feb 05, 2010 @ 19:41
    shruti
    0

    For an example 

    Nested macro : 

    <?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:template match="/">

     

        <xsl:variable name="rootTextpageNode" select="$currentPage/ancestor-or-self::node [@level = 2 and @nodeTypeAlias = 'CWS_Textpage']" />

     

        <div class="secondaryNav">

            <h3>

                <xsl:value-of select="$rootTextpageNode/@nodeName"/>

            </h3>

     

            <ul>

                <xsl:for-each select="$rootTextpageNode/node">

                    <li>

                        <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">

                            <xsl:attribute name="class">

                                <xsl:text>selected</xsl:text>

                            </xsl:attribute>

                        </xsl:if>

     

                        <a href="{umbraco.library:NiceUrl(current()/@id)}">

                            <span>

                                <xsl:value-of select="current()/@nodeName"/>

                            </span>

                        </a>

                    </li>

                </xsl:for-each>       

            </ul>

        </div>

     

    </xsl:template>

     

    </xsl:stylesheet>

     

    XSLT to read above MACRO

    <?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:template match="/">

     

    <xsl:variable name="replaceThis">

            <xsl:text>class="nofollow"</xsl:text>

    </xsl:variable>

    <xsl:variable name="replaceWith">

            <xsl:text>rel="nofollow"</xsl:text>

    </xsl:variable>

    <xsl:value-of select="umbraco.library:Replace($currentPage/data[@alias='bodyText'], $replaceThis, $replaceWith)" disable-output-escaping="yes" />

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;CWS_SubNavi&quot; runat=&quot;server&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes" />

    </xsl:template>

    </xsl:stylesheet>

     

    And this shows the contents of the page but not rendering macro . 

     

    Please advice 

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 05, 2010 @ 20:11
    Kim Andersen
    1

    Hi Shruti

    I have used the following code to render my content from a richtext editor:

    <xsl:variable name="content" select="$currentPage/data[@alias='content']"/>
    <xsl:value-of select="umbraco.library:RenderMacroContent($content, $currentPage/@id)" disable-output-escaping="yes"/>

    I used this to successfully render my content including a macro inserted into the richtext editor. Hope this helps out.

     

    /Kim A

  • Chris 69 posts 75 karma points
    Feb 09, 2010 @ 13:38
    Chris
    0

    Great snippet Kim! This is exactly what i was looking for! :)

  • shruti 21 posts 42 karma points
    Feb 10, 2010 @ 04:16
    shruti
    0

    Kim,

    That snippet worked good, i am able to displa macros , but i guess for .NET controls it does not work . As i am able to display .NET controls but not able to do postback.

    But thank you so much for your help. :)

Please Sign in or register to post replies

Write your reply to:

Draft