Copied to clipboard

Flag this post as spam?

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


  • Jesse Andrews 191 posts 716 karma points c-trib
    Oct 15, 2019 @ 22:45
    Jesse Andrews
    0

    RTE Macro error in leblender integration for umbraco 8

    I'm using a slightly modified version of the umbraco 8 port of leblender created by mirkomaty (see here). It works for the most part, but I've run into an argumentnullexception that occurs when macros are added inside a rich text editor caused by the rte value converter. Fortunately, this error only occurs when the control is rendered in the backoffice, as it works fine on the front end, so it's not a deal breaker. Currently the leblender catches the error so I have a fallback message in the backoffice, but I want make it display the actual content if possible.

    The error occurs around here, as the error message I get complains that the doc variable is null, which stems from issues with generating the sourceString variable. The call to the value converters can be found here.

    Any ideas on how to resolve this?

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Oct 16, 2019 @ 10:24
    Steve Megson
    0

    I think the null doc is actually here, which is being called from the RenderRteMacros method of the value converter.

    The problem seems to be that macros inside an RTE always use UmbracoContext.PublishedRequest.PublishedContentas the current document (which ends up being passed as that doc argument), but PublishedRequest is null in a call to LeBlender's HelperController.GetPartialViewResultAsHtmlForEditor.

    That method has access to the content ID, so I think it should be possible to set up the UmbracoContext before calling RenderPartialViewToString, allowing macros to render. Umbraco's TemplateRenderer does this in its Render method, so there should be some inspiration there.

Please Sign in or register to post replies

Write your reply to:

Draft