One of the downsides with the grid layout editor is that there are some limitations. One of the limitations is to reuse content from on page to another. A grid layout is not a recommended storage of reusable content - it simply wasn't designed for this scenario. If you wish to reuse content in multiple pages, it is still recommended that you store these pieces of content as separate content nodes, so they can be stored, cached and queried as usual.
But how do I "store these pieces of content as separate content nodes, so they can be stored, cached and queried as usual"? I'm struggling getting content to display in every document; it will only display in the document to which the document type containing the property is assigned.
Create a banner on every page with GridLayout
My "master" template code is:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
var SiteItems = CurrentPage.Site();
}
<html>
<head>
<title>
@Umbraco.Field("pageName")
</title>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div style="height:8px"></div>
@CurrentPage.GetGridHtml("SiteHeaderRow")
@RenderBody()
</body>
</html>
The "SiteHeaderRow" property is in a document type that is use for the home page.
The home page displays the "SiteHeaderRow" but other pages, that use a different document type, do not display the "SiteHeaderRow".
How should I configure the document types and templates to resolve this?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Hi Roger,
One of the downsides with the grid layout editor is that there are some limitations. One of the limitations is to reuse content from on page to another. A grid layout is not a recommended storage of reusable content - it simply wasn't designed for this scenario. If you wish to reuse content in multiple pages, it is still recommended that you store these pieces of content as separate content nodes, so they can be stored, cached and queried as usual.
https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/Grid-Layout/Grid-Layout-Best-Practices#Limitations
So I would recommend you to do the banner thing the old way with a media picker editor, else you would need to at the same banner on every page.
Hope this helps,
/Dennis
Thanks for this, Dennis.
But how do I "store these pieces of content as separate content nodes, so they can be stored, cached and queried as usual"? I'm struggling getting content to display in every document; it will only display in the document to which the document type containing the property is assigned.
Roger
Got it! Use recursive:
@Umbraco.Field("hr_header", recursive:true)
Many thanks for your help, Dennis.
Roger
is working on a reply...