In the grid, macros placed inside the Rich Text Editor are not rendering on front-end of site
I am trying to insert a macro that will create dynamic content within RTE content. When viewing the page on the front end of the site, it simply displays the macro name.
Example:
I need it to be in the RTE grid component instead of a separate macro component so I can create dynamic content inline.
I'm not. I'm using the default out of the box from Umbraco grid. The rendering is happening here /Views/Partials/Grid/Editors/Rte.cshtml
I can see where the view is parsing the umbraco internal links
@{
var value = TemplateUtilities.ParseInternalLinks(Model.value.ToString(), Current.UmbracoContext.UrlProvider);
value = TemplateUtilities.ResolveUrlsFromTextString(value);
value = TemplateUtilities.ResolveMediaFromTextString(value);
}
@Html.Raw(value)
but there isn't anything to convert the macros, which is why they aren't rendering.
I was attempting to use RteMacroRenderingValueConverter without having to build a VS Project. I'm trying to only use razor on this project for various reasons. There might be a way to do it, but I'm not familiar enough with how.
There isn't a problem with the macro partial. The macros work outside of the grid RTE. It works in a regular RTE that is added to a document type via a property. It works in the grid when using the default macro component. Rendering a macro in the view with Umbraco.RenderMacro works.
My problem is specifically about displaying a macro in the RTE via grid and what code is needed to run the default Umbraco process to convert the code Umbraco places by default in RTE (below) to a rendered macro.
I could write something to converts the macro name and moves all of the macro parameters to render the Umbraco.RenderMacro code, but it would be time-consuming. My hope was that the Umbraco API would have some type of utility that already did this.
It may not and if it's late there, you don't have to find an answer. Was just putting it out there to the masses.
My case is that i'm trying to insert a Umbraco-forms macro via the RTE in a Perplex Contentblock.
The result HTML markup contains:
<div class="umb-macro-holder renderUmbracoForm umb-macro-mce_1 mceNonEditable">
<!-- the complete umbraco form commented out in HTML -->
<ins>
[just the form labels without input elements]
</ins>
</div>
Inserting the same macro via RTE outside the content blocks (or grid) works fine.
If anybody is still looking for a solution to this, I have an updated rte.cshtml file for you! It's a quick and dirty fix and should be improved upon, but this should get you going
In the grid, macros placed inside the Rich Text Editor are not rendering on front-end of site
I am trying to insert a macro that will create dynamic content within RTE content. When viewing the page on the front end of the site, it simply displays the macro name.
Example:
I need it to be in the RTE grid component instead of a separate macro component so I can create dynamic content inline.
Thanks!
Think you're missing the attachment.
You're right. Thanks for the catch!
How are you rendering the macro?
I'm not. I'm using the default out of the box from Umbraco grid. The rendering is happening here /Views/Partials/Grid/Editors/Rte.cshtml
I can see where the view is parsing the umbraco internal links
but there isn't anything to convert the macros, which is why they aren't rendering.
I was attempting to use RteMacroRenderingValueConverter without having to build a VS Project. I'm trying to only use razor on this project for various reasons. There might be a way to do it, but I'm not familiar enough with how.
I hate to refer you to docs, but late here..
You still have to use a macro partial to render the macro, you can definitely do this in razor without VS or compiling anything: https://our.umbraco.com/documentation/reference/templating/macros/
There isn't a problem with the macro partial. The macros work outside of the grid RTE. It works in a regular RTE that is added to a document type via a property. It works in the grid when using the default macro component. Rendering a macro in the view with Umbraco.RenderMacro works.
My problem is specifically about displaying a macro in the RTE via grid and what code is needed to run the default Umbraco process to convert the code Umbraco places by default in RTE (below) to a rendered macro.
I could write something to converts the macro name and moves all of the macro parameters to render the Umbraco.RenderMacro code, but it would be time-consuming. My hope was that the Umbraco API would have some type of utility that already did this.
It may not and if it's late there, you don't have to find an answer. Was just putting it out there to the masses.
Did anyone ever figure this out?
My case is that i'm trying to insert a Umbraco-forms macro via the RTE in a Perplex Contentblock.
The result HTML markup contains:
Inserting the same macro via RTE outside the content blocks (or grid) works fine.
Unfortunately no, I never found a solution. I've just used the default "insert form" module for the grid.
If anybody is still looking for a solution to this, I have an updated rte.cshtml file for you! It's a quick and dirty fix and should be improved upon, but this should get you going
https://gist.github.com/EpicOfficer/0587a68c38454ca1e02e7138e23a04fc
is working on a reply...