Last active
March 31, 2025 14:51
-
-
Save sebastiandammark/dcb588f6cd6d8d291af9cdedda596b8b to your computer and use it in GitHub Desktop.
Unifying partial between BlockGridItem and BlockListItem
This file contains hidden or 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 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
Awesome thanks.
For future noobs like me, put @using Umbraco.Cms.Core.Models.Blocks; at the top (unless there is some global way of doing it - note the "noob" clarification from earlier).