Apologies first if this thread should have gone under
templates. I need to frig a template to
have a macro in a macro. Can anyone
assist? Code example below:
I recognise the problem you're describing. In a lot of my project I use MNTP to select blocks ( = macrofile renders it's content). When I insert a macro in the RTE of that block I had the same problem you describe.
Like said above, RenderMacroContent is the solution for this problem. Have a look at my code snippet:
SelectedContentRight are my selected blocks. Hope this helps.
@foreach (var node in selectedContentRight)
{
var elementHtml = RenderPage(GetMacro(node), node);
@(Html.Raw(umbraco.library.RenderMacroContent(elementHtml.ToString(), Model.Id)))
}
macro in a macro
Apologies first if this thread should have gone under templates. I need to frig a template to have a macro in a macro. Can anyone assist? Code example below:
<umbraco:Macro runat="server" language="cshtml">
@{
if(@Request.QueryString["ref"] == "20121338")
{
<umbraco:Macro MediaID="29259" Alias="DisplayMediaItem" runat="server"></umbraco:Macro>
}
}
</umbraco:Macro>
I appreciate this is dirty but I need a quick fix to buy me time to re-write the full macro.
Regards,
Rob
Hi
what kind of a macro are we talking about ? You can use RenderPage http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/@renderpage-with-args or umbraco.RenderMacro http://our.umbraco.org/documentation/v501/reference/templating/umbraco-helpers/umbraco_rendermacro (but not if it's an ascx)
I meant : http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent
its a cshtml macro
no joy on changing the encoding (unless i've done a school boy error). example below:
<umbraco:Macro runat="server" language="cshtml">
@{
if(@Request.QueryString["ref"] == "20121338")
{
<?UMBRACO_MACRO macroAlias="DisplayMediaItem" MediaID="29259"></?UMBRACO_MACRO>
<h1>test 1</h1>
}
else
{
<h2>test 2</h2>
}
}
</umbraco:Macro>
I recognise the problem you're describing.
In a lot of my project I use MNTP to select blocks ( = macrofile renders it's content).
When I insert a macro in the RTE of that block I had the same problem you describe.
Like said above, RenderMacroContent is the solution for this problem. Have a look at my code snippet:
SelectedContentRight are my selected blocks. Hope this helps.
is working on a reply...