Copied to clipboard

Flag this post as spam?

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


  • bparks 23 posts 79 karma points
    Mar 25, 2012 @ 11:15
    bparks
    0

    Macro in RTE not being executed

    I have a Razor macro called "RenderContentSnippet" that allows the user to choose a document as a parameter -- the macro then renders the contents of an RTE found on the selected document.  This macro is typically embedded in an RTE to support adding common content to a sidebar; for example, an editor would drop this macro into the sidebar section of a "Department" page and choose the "Common Department Links" as the parameter -- this would render the links in the Department page's sidebar.

    This works great as long as the "content snippet" document doesn't contain macros itself in its RTE -- in that case, the macro in the content snippet page doesn't execute at all, and I just see the macro markup in my HTML output.

    My question, in short:  Is it possible to embed a macro in an RTE, when the macro renders the contents of an RTE found on a second page, and have the embedded macros on the second page still execute?

    My Page -> Content (RTE) -> Contains macro "RenderContentSnippet" (parameter is id of Page X)

    RenderContentSnippet Macro -> Executes razor to output value of Page X RTE field called "ContentSnippet"

    Page X -> ContentSnippet field is an RTE that contains an embedded macro.

     

    Using v4.7.1

    thanks in advance.

  • Douglas Ludlow 210 posts 366 karma points
    Mar 26, 2012 @ 18:31
    Douglas Ludlow
    0

    You're probably going to want to use the umbraco.library.RenderMacroContent method. The following post has an example of how to use the method recursively, albeit the example is more for the backend. It probably wouldn't be to different to code it up for razor.

    http://our.umbraco.org/forum/developers/api-questions/26364-Macro-content-not-showing-up-Need-workaround

Please Sign in or register to post replies

Write your reply to:

Draft