Copied to clipboard

Flag this post as spam?

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


  • Steve Smith 75 posts 158 karma points
    May 09, 2013 @ 21:10
    Steve Smith
    0

    Inline macros in a richtext editor field output by a Razor macro

    Hi guys,

    Just taking a reality check here really, because I'm assuming what I want to do is impossible, but thought I'd check first :-)

    Large Umbraco 4.7.1.1 website.  

    For various reasons best known to the original developers, we make very little use of the <umbraco:Item> tag in our templates, and instead tend to output fields via Razor macros (eg. @Model.BodyText).  

    This was all fine until today when I wanted to make a couple of user controls available to our users to "insert" inline via the rich text editor.  

    The inline macros can be inserted via the TinyMCE editor with no problem, but when viewing the output of the page in the front-end, rather than the output of the inline macro, we instead get it's reference appearing in the client side HTML.  For example:

    <?UMBRACO_MACRO macroAlias="MyMacroAlias" /> 

    What I'm assuming is happening here, is that because we're outputting the content of the Richtext Editor field using a Razor macro, its simply outputting whatever is stored in the database for that field of that node, and the references to inline macros within the field aren't being processed/executed first.

    Assuming this is correct, I don't suppose there's any way around this - short of editing all our templates to not use Razor for outputting HTML fields?

    Steve.

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    May 13, 2013 @ 10:47
    Mike Chambers
    0

    just another thought... if you are doing any manipulation on the content rather than just a stanard umbraco insert the content here.. you might need to revist that code to add

    xmlContentString = umbraco.library.RenderMacroContent(xmlString, NodeId);

    which should take all the <?UMBRACO_MACRO /> tags that you are seeing and render then correctly)

    or if not you could perhaps use this anyway as a wrapper on inserting content to pass in what you are currently writing to the page, and force the tags to be rendered?

Please Sign in or register to post replies

Write your reply to:

Draft