Copied to clipboard

Flag this post as spam?

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


  • James J Hildeman 13 posts 104 karma points
    Oct 28, 2020 @ 01:10
    James J Hildeman
    0

    How to do "@umbraco.library.RenderMacroContent" in v8?

    What is the umbraco v8.6.1 version of the following code?

    @umbraco.library.RenderMacroContent(BodyText, Id)

  • Chris Evans 137 posts 353 karma points c-trib
    Oct 28, 2020 @ 01:48
    Chris Evans
    0

    There is documentation on that here:

    https://our.umbraco.com/Documentation/Reference/Templating/Macros/

    I think the relevant bits would be

    @Umbraco.RenderMacro("myMacroAlias")
    

    or with parameters:

    @Umbraco.RenderMacro("myMacroAlias", new { name = "Ned", age = 28 })
    

    Is that what you're after?

    Cheers,

    Chris

  • James J Hildeman 13 posts 104 karma points
    Oct 28, 2020 @ 01:52
    James J Hildeman
    0

    I need something that can parse the "<?UMBRACO_MACRO..." bits from a full text field.

    Those RenderMacro...() functions all require you to know the alias or id or name of a specific macro. I have an RTE that has the "embed macro" button turned on, so I don't know what the user might insert.

  • Chris Evans 137 posts 353 karma points c-trib
    Oct 28, 2020 @ 02:01
    Chris Evans
    0

    I haven't used Macros in a while, but I think they should render themselves if you output the content of a rich text editor onto your view? So you shouldn't need to call any custom code to do so.

    If you can share a snippet of your code that shows what you're attempting, and a screenshot of the output that might be useful to help diagnose the issue.

  • James J Hildeman 13 posts 104 karma points
    Oct 28, 2020 @ 02:07
    James J Hildeman
    0

    Here is the full problem:

    https://our.umbraco.com/forum/using-umbraco-and-getting-started/103978-umbraco-v861-macros-fail-in-rte-insert-even-simplest

    It seems that if you embed a macro through the RTE that is embedded in a grid (Insert Macro button on RTE) it doesn't parse the macro. So all my macros are useless. Even the simplest stock snippets never render. I can't believe it but it's what my eyes are seeing so I'm trying to break it down into smaller pieces.

    I think I have narrowed it down to a missing "RenderMacroContent" code in Views\Partials\Grid\Editors\rte.cshtml. enter image description here

  • Chris Evans 137 posts 353 karma points c-trib
    Oct 28, 2020 @ 02:10
    Chris Evans
    100

    Ah - I believe it's because macros inserted inside rich text editors, which are themselves inserted inside grid areas aren't supported. It's one level of inception too deep for the rendering method to handle.

    Instead, you can disable macros in the rich text editors, and let users add macros directly into grid areas as their own blocks. That way, the grid rendering engine can parse and render the macros directly.

    If you want text to be above and below a macro, just add something like this:

    • rich text editor
    • macro
    • another rich text editor

    Maybe give that a try and see if it is a workable solution?

  • James J Hildeman 13 posts 104 karma points
    Oct 28, 2020 @ 03:24
    James J Hildeman
    1

    I didn't understand your answer at first, but I think this is what you described in your solution. Correct?

    Check out the screen shot below. I went in and configured my "columns" in my "grid editor" to allow "Macros" instead of just "Rich Text Editor" and "Head Line" as they were defaulted to. As a result, the human editor can now have an 1) RTE, followed by 2) a "macro" followed by 3) RTE/Macro/Whatever! #OutOfBox

    Thanks Chris Evans for your help! Hope this helps someone else.

    enter image description here

  • Chris Evans 137 posts 353 karma points c-trib
    Oct 28, 2020 @ 07:51
    Chris Evans
    0

    That’s exactly it! Glad it was helpful for you. High five!

Please Sign in or register to post replies

Write your reply to:

Draft