Copied to clipboard

Flag this post as spam?

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


  • Håvard Rustad Olsen 6 posts 36 karma points
    Sep 01, 2015 @ 14:22
    Håvard Rustad Olsen
    0

    Using grid-layout with razor macro

    Hello, I have upgraded a project running on 4.7.2 to 7.2.8 and made it run.

    Because it is such an old project it is still using masterpages and razor macros. I was hoping to use the grid-layout, but rendering it doesn't seem to work with this setup. I'm guessing this is because the macros inherit from umbraco.MacroEngines.DynamicNodeContext and not something like UmbracoViewPage.

    Is their any way of using the grid-layout with the setup I have or is the answer that it simply isn't supported?

    Cheers, Håvard

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Sep 02, 2015 @ 10:20
    Dennis Aaen
    101

    Hi Håvard.

    Great to hear that you was able to upgrade from and old Umbraco 4.7.2 to the latest version.

    What you could do is to make a partial view or a partial view macro file, and in there add the Razor code for outputting the content of the grid.

    https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Grid-Layout/Render-Grid-In-Template

    So instead of output in directly into the template you do it though a partial view or partial view macro.

    Strongly typed Razor

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @Model.Content.GetGridHtml("propertyAlias")
    

    or the dynamic Razor

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @CurrentPage.GetGridHtml("propertyAlias")
    

    Hope this helps,

    /Dennis

  • Håvard Rustad Olsen 6 posts 36 karma points
    Sep 03, 2015 @ 08:36
    Håvard Rustad Olsen
    0

    Hi Dennis!

    That did the trick, thank you :)

    Cheers,

    Håvard

Please Sign in or register to post replies

Write your reply to:

Draft