Copied to clipboard

Flag this post as spam?

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


  • Chris Smith 38 posts 141 karma points
    Feb 13, 2015 @ 15:47
    Chris Smith
    0

    Rendering the Grid Layout On It's Parent Node

    Hi.

    We have a setup where a landing page pulls through the child node elements and displays them within itself.

    Is it possible to put a Grid on a child node and display it on the parent?  

    I've included the code we've used to loop through the child elements to pull the old RTE field and my guess at what I thought would pull through the Grid.

    <div class="tab-content">
        @foreach (var tab in modeTab.Children)
        {
            <div role="tabpanel" class="tab-pane @tab.Id">
                @*@Html.Raw(tab.GetPropertyValue("tab1ContentLower"))*@
                @tab.GetGridHtml("tab1ContentLower")
            div>
        }
    div>

    Looking through some other forum posts it looks like others have tried to add a grid to the parent and display it on a child but its not currently possible so I'm guessing what I'm trying isn't eiether.

    Cheers

    Chris 

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Feb 13, 2015 @ 16:16
    Dennis Aaen
    0

    Hi Chris,

    From the documentation, it´s not able to reuse the content from a grid layout on other pages.

    Try to see https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/grid-layout documentation on the grid layout and specific this section abut limitations. https://our.umbraco.org/Documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Grid-Layout-Best-Practices#Limitations

    It says - With the above usage scenarios in mind, consider the grids limitations. First of all, all content entered into the grid is stored as a single property value on the content node, as a big JSON object. This means that as soon as the values are stored in the database, there is no managed api to drill into the grid content and target specific cell content - so a grid layout is not a recommended storage of reusable content

    Hope this helps,

    /Dennis

  • Chris Smith 38 posts 141 karma points
    Feb 13, 2015 @ 16:32
    Chris Smith
    0

    Thanks Dennis.

    I had seen the best practice page but hoped I had not understood it properly!  In this specific scenario bringing back the entire grid would have been fine as we didn't need to drill into specific elements.

    Thanks for the quick response.

    Cheers

    Chris

  • Michael Taylor 5 posts 75 karma points
    Nov 13, 2018 @ 11:09
    Michael Taylor
    0

    Hi Chris,

    I know this is from a while back, but can't easily find anything more recent that answers this.

    I've been able to get this to work. Essentially I have a "Home" page for the site with a "Site Settings" node beneath it. In my Master template I fetch all the "Site Settings" content using the following:

    IPublishedContent siteSettings = homeNode.Children.FirstOrDefault(x => x.DocumentTypeAlias == "siteSettings");
    

    For simple text field content I use:

    if (siteSettings.GetProperty("companyName") != null && siteSettings.GetPropertyValue("companyName") != null)
    {
        companyName = siteSettings.GetPropertyValue("companyName").ToString();
    }
    

    Then for the grid content stored in "Site Settings" I do the following:

    MvcHtmlString footerContent = MvcHtmlString.Empty;
    
    if (siteSettings.GetProperty("footerContent") != null && siteSettings.GetPropertyValue("footerContent") != null)
    {
        footerContent = Html.GetGridHtml(siteSettings, "footerContent", "Bootstrap3-Fluid");
    }
    

    I hope that helps (and works for you).

    Keep well, Michael

Please Sign in or register to post replies

Write your reply to:

Draft