Copied to clipboard

Flag this post as spam?

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


  • Ryan Morrin 1 post 21 karma points
    Mar 12, 2015 @ 15:36
    Ryan Morrin
    0

    Render contents of Macro Container

    Hi all,

    I am trying to output the contents of a macro container (containing multiple parameterized macros) in a Razor template but have been having trouble. I have listed everything already tried below. Assuming contentContainer is the alias of my macro container property:

    • @Umbraco.Field("contentContainer") Nothing
    • @Model.Content.GetPropertyValue("contentContainer") Nothing
    • @Html.Raw(umbraco.library.RenderMacroContent(CurrentPage.contentContainer, CurrentPage.Id)) Nothing
    • @Model.Content.GetProperty("contentContainer").Value Nothing
    After a bit of debugging, I've noticed that the 'Value' of my property doesn't actually contain any data. However, the 'DataValue' field looks to contain some data relating to the macros in the container:  
      
    Obviously I can reference the 'DataValue' field directly, but this goes against all the suggestions I've seen so far.  
    I've also been unable to locate any documentation on iterating through each macro inside a macro container (I am allowing up to 3 to be inserted). Any information on this would also be appreciated, as this is the next step.
    Thanks

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 15, 2015 @ 09:59
    Jan Skovgaard
    0

    Hi Ryan and welcome to our :)

    Did you ever find a way to solve this? If not could you then please let us know what exact version of Umbraco you'e using? Then it's possible to figure out if it might be caused by a bug or if the way to render it has changed for instance.

    /Jan

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 16, 2015 @ 08:48
    Stefan Kip
    0

    I'm having the same kind of issue. The value of a richtext editor property stored in a C# string and I'd like to render it, including a UserControl Macro.
    I've tried umbraco.library.RenderMacroContent and the output is in fact the UserControl, but the real content of the UserControl is missing, because OnLoad isn't even called at all.
    So now I'm using <umbraco:Item runat="server" Field="description" /> which works, but it's not really what I'm looking for...

Please Sign in or register to post replies

Write your reply to:

Draft