Copied to clipboard

Flag this post as spam?

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


  • Susanto 7 posts 27 karma points
    Aug 12, 2009 @ 08:16
    Susanto
    0

    Umbraco Macro Render another macro

    Hi,

    How to render umbraco macro from another macro?

    I have umbraco macro, reading the richtexteditor from other content (which might content another macro).

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Aug 12, 2009 @ 08:22
    Richard Soeteman
    1

    Hi,

    Don't know if this is possible. You can call a macro that is using xslt(Other macro types is not possible) from a macro. In the example below I call a macro with alias ShowContentImage. As you can see you'll have to encode the string otherwise it will fail your xslt to save. 

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;ShowContentImage&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes"/>
  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Aug 12, 2009 @ 08:23
    Richard Soeteman
    0

    Hereby the example again

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

  • Susanto 7 posts 27 karma points
    Aug 12, 2009 @ 08:34
    Susanto
    0

    I did try the umbraco.library:RenderMacroContent. The function just render the content, which I guess what's the function name call :)

    But my macro reading the content from richtext editor field, which contain another macro happen to be .ascx control. It does render the control without execute the code-behind. Any idea how to execute the code-behind?

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Aug 12, 2009 @ 10:05
    Richard Soeteman
    0

    I think you can't. Rendering a normal Macro that uses a Usercontrol is not possible in a Macro so I think this is also the case with you scenario.

  • Chris Koiak 700 posts 2626 karma points
    Aug 12, 2009 @ 10:28
    Chris Koiak
    0

    Remember that a UserControl can be loaded from another UserControl using

    this.LoadControl("/usercontrols/AnotherControl.ascx");

    This might achieve what you're looking for.

  • Susanto 7 posts 27 karma points
    Aug 13, 2009 @ 02:51
    Susanto
    0

    My macro reading the richtexteditor field, the publisher might insert few macros into it.

    umbraco.library:RenderMacroContent function able to execute properly if the richtexteditor contain xslt macro, no luck with usercontrol as it won't execute the code behind.

    It will be great if it's support macro from usercontrol.

  • Chris Koiak 700 posts 2626 karma points
    Aug 13, 2009 @ 10:04
    Chris Koiak
    0

    Is there anyway to achieve what your trying by using an ITemplate?

    Your macro/control reading the richtextarea could contain an ITemplate, then you would be able to read the data from the RTE and use the InstantiateIn() method of ITemplate.

    Other than that I'd get the Umbraco code and find out how it initiates the RTE content... and steal emulate that functionality.

Please Sign in or register to post replies

Write your reply to:

Draft