Copied to clipboard

Flag this post as spam?

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


  • kylepauljohnson 70 posts 108 karma points
    Jul 01, 2010 @ 06:02
    kylepauljohnson
    0

    Loading a Macro from a RichTextArea via XSLT

    Hey everyone, I have a fairly complicated issue to explain, so I am trying to outline the requirements below.

    1. Using a UltimatePicker from one piece of content to get content ID's of some widgets I want to load.
    2. Via XSLT splitting the comma separated values
    3. Some of these items contain raw HTML, and some contain Macros.
    4. The items containing HTML work fine, and I can hard code a Marco as seen in the code, but if the widget contains a Macro via the RichTextArea I am not sure how to make these render.
    Any pointers that you could provide would be awesome.  Thanks everyone.
    Current XSLT is below.
    <?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" />
        <xsl:variable name="foreignNodeId" select="$currentPage/data[@alias='sideBarContent']" />
        <xsl:variable name="foreignNode" select="umbraco.library:GetXmlNodeById($currentPage/data[@alias='sideBarContent'])" />
        <xsl:template match="/">
          
        <xsl:variable name="nodesList" select="umbraco.library:Split($currentPage/sideBarContent, ',')"/>     
            
          <xsl:for-each select="$nodesList/value">
            <xsl:value-of select="umbraco.library:GetXmlNodeById(.)" disable-output-escaping="yes"/>
            <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;AuthenticJobs&quot;&gt;&lt;/?UMBRACO_MACRO&gt;&quot;', '1106')" disable-output-escaping="yes"/>
            
            <!--<xsl:value-of select="umbraco.library:HtmlEncode('String Text')"/>-->
            
            </xsl:for-each>
        
        </xsl:template>
    </xsl:stylesheet>

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 01, 2010 @ 06:13
    Aaron Powell
    0

    Are you trying to load a .NET macro or an XSLT macro from the XSLT macro? IIRC you can't load .NET macros from XSLT.

  • kylepauljohnson 70 posts 108 karma points
    Jul 01, 2010 @ 06:14
    kylepauljohnson
    0

    Right, they would be .NET controls.  So this is not doable.  Any recommendations on how one might go about this in any other way?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 01, 2010 @ 06:22
    Aaron Powell
    0

    Do it entirely in .NET. You can then even compress it into a single macro.

    But if you really must have it has 2 macros you can have something like this:

    <asp:Repeater runat="server" DataSource="<%# this.SomeProperty.Split(',') %>">
        <ItemTemplate>
            <umbraco:Macro runat="server" alias="MyOtherMacro" ThePropertyToSet="<%# Container.DataItem %>" />
        </ItemTemplate>
    </asp:Repeater>

    That's just really stubbed out code to show the example, obviously you should change it to match really what you want.

    To get info about the current node (or any node) in .NET use the you can use the UmbracoContext object (if you're in Umbraco 4.5) or nodeFactory.Node (if you're in Umbraco 4.0)

  • kylepauljohnson 70 posts 108 karma points
    Jul 01, 2010 @ 06:32
    kylepauljohnson
    0

    I have yet to do things like that in .net, are there any good examples or references you could point me to?

Please Sign in or register to post replies

Write your reply to:

Draft