Skip to content

Instantly share code, notes, and snippets.

@sebastiandammark
Last active September 23, 2024 09:06
Show Gist options
  • Save sebastiandammark/dcb588f6cd6d8d291af9cdedda596b8b to your computer and use it in GitHub Desktop.
Save sebastiandammark/dcb588f6cd6d8d291af9cdedda596b8b to your computer and use it in GitHub Desktop.
Unifying partial between BlockGridItem and BlockListItem
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<IBlockReference>
@using Umbraco.Cms.Web.Common.PublishedModels
@{
var block = Model switch
{
BlockGridItem gridItem => gridItem.Content as TextBlock,
BlockListItem listItem => listItem.Content as TextBlock,
_ => null
};
var settings = Model switch
{
BlockGridItem gridItem => gridItem.Settings as TextBlockSettings,
BlockListItem listItem => listItem.Settings as TextBlockSettings,
_ => null
};
if(block != null){
<div class="textblock">
<h1>@block.Title</h1>
<div>@block.Text</div>
</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment