Copied to clipboard

Flag this post as spam?

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


  • Karima 2 posts 92 karma points
    Jun 05, 2019 @ 10:36
    Karima
    0

    Macro + Rte

    I added a parameter of type "RTE" in my Macro. but I can't get its value correctly. In the cshtml file, I add this to get the value of the parameter:

    @Html.Raw(TemplateUtilities.ParseInternalLinks(Model.MacroParameters["Introduction"].ToString(), Current.UmbracoContext.UrlProvider))

    but the result is not in html:

    kgkgkkgkg kggkkg
    <br />jjjj.

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 06, 2019 @ 10:36
    Brandon Osborne
    1

    Hello There, Karima,

    I would say to first look at the source in your RTE and make sure the HTML isn't coming out HTMLEncoded (i.e. <br /> ). If it is correct it in the HTML or change your code to:

    @Html.Raw(Server.HtmlDecode(TemplateUtilities.ParseInternalLinks(Model.MacroParameters["Introduction"].ToString(), Current.UmbracoContext.UrlProvider)))
    

    I've seen the RTE occasionally do this and mess up the results that I'm expecting. Let me know if that fixes your issue or if the problem persists.

  • Karima 2 posts 92 karma points
    Jun 06, 2019 @ 10:46
    Karima
    100

    Hi Brandom,

    Thank you for your response, I found the solution :

    var myString = Model.MacroParameters["Introduction"].ToString();
      @Html.Raw(HttpUtility.HtmlDecode(myString))
    
  • Erik W 4 posts 83 karma points
    Jun 27, 2019 @ 10:41
    Erik W
    0

    Hi, how did you add the RTE in V8?

    I tried to use this guide but cant get it to work: https://our.umbraco.com/forum/templates-partial-views-and-macros/82089-tinymce-as-macro-parameter

  • Thomas Beckert 193 posts 469 karma points
    Jun 09, 2021 @ 09:18
    Thomas Beckert
    0

    To Render RTE Content passed by Macro-Paraemter and also render internal links! use this code:

    @using Umbraco.Web.Templates;
    @using Umbraco.Web.Composing;
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        HtmlLocalLinkParser htmlLocalLinkParser = new HtmlLocalLinkParser(Current.UmbracoContextAccessor);
        string text = Model.MacroParameters["textFromRTE"].ToString();    
    }
    
    @Html.Raw(htmlLocalLinkParser.EnsureInternalLinks(Server.HtmlDecode(text)))
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies