Created
April 16, 2017 00:35
-
-
Save jamiepollock/f2ed2be6744a8bd0f6b48cdd22fbed5a to your computer and use it in GitHub Desktop.
Example of Umbraco GridSettings using the Bootstrap3.cshtml with Umbraco v7.5.4+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits UmbracoViewPage<dynamic> | |
@using Umbraco.Web.Templates; | |
@using Newtonsoft.Json.Linq; | |
@using Our.Umbraco.GridSettings.Web; | |
@using Our.Umbraco.GridSettings.Services; | |
@using Our.Umbraco.GridSettings.Resolvers; | |
@{ | |
var attributesResolver = new GroupByPrefixTokenGridSettingsAttributesResolver("_"); | |
var attributesService = new GridSettingsAttributesService(attributesResolver); | |
} | |
@if (Model != null && Model.sections != null) | |
{ | |
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; | |
<div class="umb-grid"> | |
@if (oneColumn) | |
{ | |
foreach (var section in Model.sections) | |
{ | |
<div class="grid-section"> | |
@foreach (var row in section.rows) | |
{ | |
@renderRow(row, true, attributesService); | |
} | |
</div> | |
} | |
} | |
else | |
{ | |
<div class="container"> | |
<div class="row clearfix"> | |
@foreach (var s in Model.sections) | |
{ | |
<div class="grid-section"> | |
<div class="col-md-@s.grid column"> | |
@foreach (var row in s.rows) | |
{ | |
@renderRow(row, false, attributesService); | |
} | |
</div> | |
</div> | |
} | |
</div> | |
</div> | |
} | |
</div> | |
} | |
@helper renderRow(dynamic row, bool singleColumn, IGridSettingsAttributesService<JObject> attributesService) | |
{ | |
<div @Html.RenderGridSettingAttributes(row as JObject, attributesService)> | |
@Umbraco.If(singleColumn, "<div class='container'>") | |
<div class="row clearfix"> | |
@foreach (var area in row.areas) | |
{ | |
<div class="col-md-@area.grid column"> | |
<div @Html.RenderGridSettingAttributes(area as JObject, attributesService)> | |
@foreach (var control in area.controls) | |
{ | |
if (control != null && control.editor != null && control.editor.view != null) | |
{ | |
<text>@Html.Partial("grid/editors/base", (object)control)</text> | |
} | |
} | |
</div> | |
</div>} | |
</div> | |
@Umbraco.If(singleColumn, "</div>") | |
</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment