Displaying RTE field that has a Macro inside of it.
I'm trying to create a sidebar widgets module. This would require me to create list of nodes and display their content. The nodes basically have two values, a textbox and a RTE. Inside the RTE, I'm displaying different macros, either Razor or XSLT.
Is this possible to do in Umbraco 4.7?
I'm using @Html.Raw(node.mainContent.ToString()); to display the value from the field. The html is working correctly, but when I view source, I see the following:
as far as I can tell, neither of these options work when you are in a .cshtml file. Both of those options work when in a .aspx and .ascx file. I'm trying to do all of the code and all of the rendering using Razor.
Displaying RTE field that has a Macro inside of it.
I'm trying to create a sidebar widgets module. This would require me to create list of nodes and display their content. The nodes basically have two values, a textbox and a RTE. Inside the RTE, I'm displaying different macros, either Razor or XSLT.
Is this possible to do in Umbraco 4.7?
I'm using @Html.Raw(node.mainContent.ToString()); to display the value from the field. The html is working correctly, but when I view source, I see the following:
<?UMBRACO_MACRO macroAlias="Copyright" />
Thanks!
-C
Yeah that won't work :-(
You'd have to use 'umbraco:item': http://our.umbraco.org/wiki/reference/templates/umbracoitem-element
So I tried to do this inside my Razor method.
Item currentItem = new Item();
currentItem.NodeId = currentNode.Id.ToString();
currentItem.Field = "mainContent";
But how do you render it?
-C
Well you can use this in your template:
Or you can create it with code and add it to the Controls collection of a ASP.net PlaceHolder:
Yeah, that is the code that I had in my old control. I was trying to move the code out of the compiled control and into Razor.
But at the moment, I can't seem to find out how to render it.
-C
Well I just gave ya two options... What's the prob?
as far as I can tell, neither of these options work when you are in a .cshtml file. Both of those options work when in a .aspx and .ascx file. I'm trying to do all of the code and all of the rendering using Razor.
Sorry, can't help ya then... Haven't played with razor yet unfortunately!
Finally found it with the help of the code from http://our.umbraco.org/projects/website-utilities/rndr-url-macro-renderer
@Html.Raw(umbraco.library.RenderMacroContent(content, currentNode.Id));
-C
Nice work mate!
is working on a reply...