Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Block List Grid Rendering

Note, the filenames indicate where they should be stored. So Views-Partials-BlockGrid.cshtml means it should be in Views/Partials/BlockGrid.cshtml

@inherits UmbracoViewPage<BlockListItem<ContentModels.Embed>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
<div class="video-wrapper">
<iframe width="320" height="240" src="@Model.Content.EmbedUrl" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
@inherits UmbracoViewPage<BlockListItem<ContentModels.Headline>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
<h1>@Model.Content.HeadlineText</h1>
@inherits UmbracoViewPage<BlockListItem<ContentModels.ImageBlock>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
@if (Model.Content.Image != null)
{
<img src="@Model.Content.Image.Url()">
}
@if (!Model.Content.Caption.IsNullOrWhiteSpace())
{
<p class="caption">@Model.Content.Caption</p>
}
@inherits UmbracoViewPage<BlockListItem<ContentModels.RichTextEditor>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
@Model.Content.Content
@inherits UmbracoViewPage<BlockListItem<ContentModels.FullWidthSection>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
<div class="row">
<div class="col-md-12">
@foreach (var block in Model.Content.MainColumn)
{
<div>
@Html.Partial("BlockGrid/Blocks/" + block.Content.ContentType.Alias, block, new ViewDataDictionary { { "udis", Model.Content.MainColumn.Select(x => x.ContentUdi) } })
</div>
}
</div>
</div>
@inherits UmbracoViewPage<BlockListItem<ContentModels.TwoColumnSection>>
@using Umbraco.Core.Models.Blocks
@using ContentModels = Umbraco.Web.PublishedModels
<div class="row">
<div class="col-md-4">
@foreach (var block in Model.Content.AsideColumn)
{
@Html.Partial("BlockGrid/Blocks/" + block.Content.ContentType.Alias, block)
}
</div>
<div class="col-md-8">
@foreach (var block in Model.Content.MainColumn)
{
@Html.Partial("BlockGrid/Blocks/" + block.Content.ContentType.Alias, block)
}
</div>
</div>
@inherits UmbracoViewPage<BlockListModel>
@using Umbraco.Core.Models.Blocks
@if (Model != null)
{
<div class="umb-grid">
@foreach (var section in Model)
{
@Html.Partial("BlockGrid/Sections/" + section.Content.ContentType.Alias, section)
}
</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment