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.
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.
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?
I think the null
doc
is actually here, which is being called from theRenderRteMacros
method of the value converter.The problem seems to be that macros inside an RTE always use
UmbracoContext.PublishedRequest.PublishedContent
as the current document (which ends up being passed as thatdoc
argument), butPublishedRequest
is null in a call to LeBlender'sHelperController.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'sTemplateRenderer
does this in itsRender
method, so there should be some inspiration there.is working on a reply...