https://discord.umbraco.com logo
#help-with-umbraco
Block Grid: Reusable layout template file
# help-with-umbraco
a

abra8140

02/01/2024, 1:32 PM
I'm experimenting with the Block Grid feature and trying to understand how to set up various layouts. Currently, we use a Document Type Grid Editor that allows for a grid layout with four distinct column configurations: Two columns with a 66% / 33% split Two columns with an 83% / 16% split Four columns, each 25% width A single full-width column I've created an element type for the layout and defined the Areas within the Block Grid settings. Additionally, I've made a corresponding .cshtml file for the element type that contains the following line: @await Html.GetBlockGridItemAreasHtmlAsync(Model) However, when I attempt to add another Block using the same element type to specify a different area layout, the option is disabled. I guess it is becuase I have already added that element type. Do I need to create a separate element type and associated template file for each of my layout definitions, even though the template only includes the line @await Html.GetBlockGridItemAreasHtmlAsync(Model)? Ideally, I'd like to be able to reuse the template for different layouts. Is this possible?
d

deanleigh

02/01/2024, 2:08 PM
Hey @abra8140 I have made a dotnet new template called UmBootstrap that exemplifies most of what can be done with Block Grid and Block List. You can install it as an example website with one click of a button in Visual Studio or a single command: https://umbootstrap.com/
Please let me know if you need any further help but I am sure if you look at the back office and the code it will have everything you need.
a

abra8140

02/01/2024, 2:25 PM
Thanks, looking at your Partials/blockgrid/Components folder I see that you have mulitple layout files that are identitical. I guess there is no way to reuse the same file?
d

deanleigh

02/02/2024, 9:45 AM
The way Block Grid works is it requires a partial with the same name. There may of course be differences in the code it just so happens in this case there is not.
2 Views