Skip to content

Instantly share code, notes, and snippets.

@sotirisf
Created December 13, 2020 17:14
Show Gist options
  • Save sotirisf/9920e28bc3b1ac934d387e901b5b229a to your computer and use it in GitHub Desktop.
Save sotirisf/9920e28bc3b1ac934d387e901b5b229a to your computer and use it in GitHub Desktop.
uMazel 2.0 block elements handling
@using Umbraco.Web.PublishedModels;
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
if (!(Model is IAbstractPageSections)) { return; }
var introBlock = (Model as IAbstractPageSections).IntroSection;
if (introBlock.Any(x => (x.Content as IAbstractSectionBlock).Disabled == false))
{
@Html.Partial(MVC.Shared.Views.Common._RenderBlock, introBlock.Where(x => !(x.Content as IAbstractSectionBlock).Disabled).FirstOrDefault())
}
var blocks = (Model as IAbstractPageSections).Sections;
if (!blocks.Any()) { return; }
foreach (var block in blocks.Where(x => (x.Content as IAbstractSectionBlock).Disabled == false))
{
@Html.Partial(MVC.Shared.Views.Common._RenderBlock, block)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment