Copied to clipboard

Flag this post as spam?

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


  • Alex Burr 77 posts 128 karma points
    Jan 16, 2014 @ 19:42
    Alex Burr
    0

    Using Content Picker in Macro Container property

    Hi,

    I'm running v7.0.1 and setting up a new website. I have a macro called GJSSubNavigation that renders ~/Views/MacroPartials/GJSSubNavigation.cshtml. It has one parameter, startNodeID, that is a content picker. 

    There is a document type called GJSPage that uses a template GJSPage.cshtml. The document type has a property called sidebarMacro that is a macro container.

    However when I attempt to assign the GJSSubNavigation macro to the sidebarMacro property on the page, and choose the appropriate node, the content does not render correctly. Instead the macro alias and start node are output in an HTML comment.

    The file GJSSubNavigation.cshtml contains:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @if (Model.MacroParameters["startNodeID"] != null)
    {
        @* Get the start node as a dynamic node *@
        var startNode = Umbraco.Content(Model.MacroParameters["startNodeID"]);
    
        if (startNode.Children.Where("Visible").Any())
        {
            <ul>
                @foreach (var page in startNode.Children.Where("Visible"))
                { 
                    <li><a href="@page.Url">@page.Name</a></li>
                }
            </ul>
        }    
    }

    And GJSPage.cshtml template contains:

    ...
    <aside>
            @Umbraco.Field("sidebarMacro")
    </aside>
    ...

    The final page that is output has the following:

    ...
    <aside>
            <!--?UMBRACO_MACRO macroAlias="GJSSubNavigation" Start Node ID="1048" /-->
    </aside> ...

    The macro alias and ID of the start node appear to be correct, however the macro content is not being rendered.

    Does anyone have experience with this?

Please Sign in or register to post replies

Write your reply to:

Draft