Copied to clipboard

Flag this post as spam?

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


  • Fengelz 106 posts 221 karma points
    Jun 15, 2011 @ 10:38
    Fengelz
    0

    Rendering RTE with embedded macros in Razor

    Anybody has any take on how to render richtext properties with embedded macros?

    When I use @Model.bodyText it just gives me the embedded macro code (which makes good sense i suppose).

    I could of course make a custom functionality that searches for embedded macros, but was wondering if umbraco already had this sort of functionality?

    best regards 

    - Sune

  • Fengelz 106 posts 221 karma points
    Jun 15, 2011 @ 11:15
    Fengelz
    5

    Ok to answer my own question: @Html.Raw(umbraco.library.RenderMacroContent(Model.bodyText, Model.Id)) seemd to do the trick.

     

  • Murray Roke 503 posts 966 karma points c-trib
    Sep 07, 2011 @ 23:08
    Murray Roke
    5

    Thanks Fengelz, I found I had to do this:

    @Html.Raw(umbraco.library.RenderMacroContent(Model.secondaryBodyText.ToString(), Model.Id))
  • Fengelz 106 posts 221 karma points
    Sep 19, 2011 @ 11:06
    Fengelz
    0

    Yeah. 

    Usually a good idea to stringify properties in razor. You never know what you'll be getting... :)

  • Sam Moore 27 posts 112 karma points
    Feb 07, 2012 @ 20:47
    Sam Moore
    0

    so I need some help with this. I can get the helper to render something, but it's not rendering the media item's umbracoFile property :-\... this macro works everywhere else on the site except through this helper call. It appears as if my macro params are not being populated correctly. Any Idea what is causing this?

    @umbraco.library.RenderMacroContent(node.BodyText.ToString(), (int)node.Id)

     

    The macro is configured like this:

      <?UMBRACO_MACRO showcaption="1" mediaitem="65663"
    largeitem="65382" macroAlias="InsertImageItem"
    enlargeimage="1" /> 

     

    The macro looks like this in the code-behind of the ascx:

    public partial class WRO_InsertImage : System.Web.UI.UserControl
        {
            public int mediaItem { get; set; }
            // snip other params
    
            protected void Page_Load(object sender, EventArgs e)
            {
                // try to get media item
                Media m = new Media(mediaItem);
                if (m == null)
                    return;
    
                // snip the rest for clarity
            }
        }
    
  • Steven Horler 11 posts 57 karma points
    Sep 03, 2012 @ 11:54
    Steven Horler
    1

    I had the same problem as Sam and had to convert my user control to a Razor script instead to get the macro to render :(

     

  • wolulcmit 357 posts 693 karma points
    May 21, 2013 @ 14:15
    wolulcmit
    0

    I had the same problem trying to get oEmbed and insert video to work with uBlogsy

    Redengine came to the rescue, as its razor based rather than a User control

    http://our.umbraco.org/projects/website-utilities/redengine-video-embed

Please Sign in or register to post replies

Write your reply to:

Draft