Umbraco 4.7.0 Macro not rendering when inserted via Richtext editor
I am using umbraco v4.7.开发者_StackOverflow0. I have created a Macro for a Usercontrol.ascx and adding it the usual way, and ticking the option "Use in editor".
It renders fine in the RTE, but then when viewing the page it does not load the macro.
I have googled for a while now and cannot find a solution to this problem, also I have been on the umbraco forum/bug lists to see that there are various posts but I havent found a solution to this yet.
Am I missing something simple here? This worked fine in previous versions.
Got an answer finally........in the template masterpage use:
<umbraco:Item field="bodyContent" runat="server"></umbraco:Item>
instead of something like
@Model.bodyContent
So that the macro (the one added via the RTE) itself isn't added by another macro (in this case the one displaying "bodyContent" field).
If, as explained in the initial question, what you see in your HTML is something like
<?UMBRACO_MACRO macroAlias="macroNameHere" />
...and you don't see anything rendered. Then this is a solution for you:
Inside the XSLT (macro) that processes your document type, you may have something like this:
<xsl:value-of select="$currentPage/bodyText" />
Change it to:
<xsl:value-of select="umbraco.library:Item($currentPage/@id,'bodyText')" />
This will render the macro contained in your bodyText.
Please note that umbraco will create a DIV around the macro output. To get rid of that DIV you have either to modify the umbraco source code, or do for example a jQuery search and replace to get rid of it.
You're usercontrol probably requires
<form runat="server">
Try inserting it in the template instead - that created a server error for me, and I found the problem!
Something like this:
<form runat="server">
<asp:ContentPlaceHolder ID="mainContent" runat="server" />
</form>
Where You put Your usercontrol in the placeholder.
To Use Macro in Richtext box
you must check the “Use in editor” checkbox under “macro properties” tab.
And In XSLT when you are printing macro value used following
<xsl:value-of select="umbraco.library:Item(@id,'bodyContent')" />
to render macro value.
Instead of
<xsl:value-of select="bodyContent" />
精彩评论