Copied to clipboard

Flag this post as spam?

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


  • Giles Dermody 14 posts 35 karma points
    Jul 05, 2011 @ 12:38
    Giles Dermody
    0

    Razor macro not rendering when added via Richtext Editor

    I don't think this has been asked before on this forum but I was wondering if anyone has encountered the problem highlighted here: http://stackoverflow.com/questions/5868578/umbraco-4-7-0-macro-not-rendering-when-inserted-via-richtext-editor .

    Basically, I'm using Umbraco 4.7 and cannot get any macro to render on my site when added via the RTE. Upon inspecting the source, all I can see is something like:

    <!--?UMBRACO_MACRO formguid="1caf0b16-ee5f-4f08-97c5-4116ac618698" macroAlias="umbracoContour.RenderForm" /-->

    Obviously the macro I was trying to render there was a contour form. However, I have gotten the same result when trying to output a macro as simple as listing the children of the current node.

    I can avoid this problem by embedding the macro directly inside a new template but this is multiplying the number of templates/document types that should really be necessary and is proving rather cumbersome when all I want to do is add an individual macro to a particular page.

    Anyone have a solution to this? Is this a new or known issue?

    Thanks,

    Giles

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 05, 2011 @ 12:43
    Sebastiaan Janssen
    0

    Unfortunately, you can't render a macro in the richtext editor in another macro (your Razor macro). 

    See these posts for more information: http://our.umbraco.org/forum/umbraco-pro/contour/16794-Umbraco-Contour-No-macro-content-available-for-WYSIWYG-editing / http://our.umbraco.org/forum/developers/extending-umbraco/19003-macro-in-rich-text-editor-wont-work

    Maybe you can use Razor to find the macro call and use the RenderMacroContent call to render it anyway. 

     

  • Giles Dermody 14 posts 35 karma points
    Jul 05, 2011 @ 12:47
    Giles Dermody
    0

    It renders fine from within viewing it inside the editor, just not on the site.  Are you saying I simply can't add razor macros from the RTE and should make a specific template with them added instead, or that I need to use "umbraco.library.RenderMacroContent" ? If the former is true then perhaps in a future release  the "add macro" option in the RTE should have some way of excluding macro's that depend on razor if they can't be added this way

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 05, 2011 @ 12:56
    Sebastiaan Janssen
    0

    I think it should work when you put this in your template/masterpage (assuming your RTE is called bodyText):

    <umbraco:Item field="bodyText" runat="server"></umbraco:Item>

    The problem is that you can't directly render a macro from a macro (even in XSLT).

  • Giles Dermody 14 posts 35 karma points
    Jul 05, 2011 @ 12:59
    Giles Dermody
    0

    Works a treat. Thanks a lot

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 11, 2011 @ 17:39
    Sebastiaan Janssen
    1

    Just an update, you can get it to work in Razor as well, like this: http://our.umbraco.org/forum/developers/razor/21275-Rendering-RTE-with-embedded-macros-in-Razor

  • Comment author was deleted

    Jul 11, 2012 @ 11:07

    You can't render a Contour form with umbraco.library.RenderMacroContent as it will not render properly. It would however be great if the support for rendering contour forms through razor could be added to 4.x as you sometimes are required to use razor to render contour forms if you want to create a well structured solution.

Please Sign in or register to post replies

Write your reply to:

Draft