Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan Woulfe 422 posts 1580 karma points MVP 3x c-trib
    Sep 11, 2012 @ 01:40
    Nathan Woulfe
    0

    @RenderPage equivalent for xslt

    I'm trying to render an xslt macro from within an inline razor macro - is this even possible?

    I thought using the following would work:

    @Html.Raw(umbraco.library.RenderMacroContent("macroAlias", Model.Id))     

    But apparantly not - the output is 'macroAlias'

    I'm using xslt to build the navigation, which I want to display conditionally from within a razor macro - if it was all razor I'd use @RenderPage()...

    Any ideas?

    Nathan

     

  • Rich Green 2246 posts 4006 karma points
    Sep 11, 2012 @ 01:43
    Rich Green
    0

    Hi Nathan,

    I'm not really sure what you're wanting to achieve but this might help http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent

    Rich

     

  • Rich Green 2246 posts 4006 karma points
    Sep 11, 2012 @ 01:47
    Rich Green
    0

    Just re-read that, you're trying to render an XSLT macro from Razor, I have no idea if this can be done.

    Rich

  • Nathan Woulfe 422 posts 1580 karma points MVP 3x c-trib
    Sep 11, 2012 @ 01:55
    Nathan Woulfe
    0

    Hi Rich

    The example below might be clearer - I want to use an inline razor macro, and depending on the node type, either render a razor or xslt macro. Works fine for the if condition, but the else renders the macro alias

    <div id="leftContentContainer">
    <umbraco:macro runat="server" language="cshtml">
    @{
    if (Model.NodeTypeAlias == "LandingPage") {
    @RenderPage("~/macroScripts/Sidebar.cshtml)
    }
    else {
    <nav id="navigationContainer" role="complementary">
    @Html.Raw(umbraco.library.RenderMacroContent("xsltNavigation", Model.Id))
    </nav>
    }
    }
    </umbraco:macro>
    </div>

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 11, 2012 @ 14:09
    Chriztian Steinmeier
    0

    Hi Nathan,

    The argument to RenderMacroContent() is not the macro alias - it was intended for use with a bodyText (RTE) field containing on or more macros inserted fomr the GUI.

    You should probably be able to do this then:

    RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"xsltNavigation\" />", Model.Id)

    I'm not sure about the quote-escaping in Razor, but I think you should be able to get it right.

    /Chriztian

  • Nathan Woulfe 422 posts 1580 karma points MVP 3x c-trib
    Sep 12, 2012 @ 00:57
    Nathan Woulfe
    0

    Chriztian - that works perfectly. I though I'd tried something along those lines, must have just missed the mark. Thanks for the advice.

    N

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies