Skip to content

Instantly share code, notes, and snippets.

@MineshS
Created September 13, 2023 16:32
Show Gist options
  • Save MineshS/7884ccc007171df8bb1d7c25b00fe78c to your computer and use it in GitHub Desktop.
Save MineshS/7884ccc007171df8bb1d7c25b00fe78c to your computer and use it in GitHub Desktop.
PromoBlock Frontend Razor View
@using EPiServer.Core
@using Netcel.Optimizely.Core.Extensions.Helpers
@using Netcel.Optimizely.Core.TagHelpers
@model PromoBlock
<div class="promoBlockWrap">
@if (Model.PromoImage != null)
{
<div class="image" @Html.EditAttributes(x=>x.PromoImage)>
<img image-for="@Model.PromoImage" css-class="promoBlockImage" fit="cover" FlexibleAttribute="Goes Here"/>
</div>
}
<div class="text">
<div class="textWrap">
<h2 class="promoBlockTitle" @Html.EditAttributes(x=>x.Title)>
@Html.DisplayFor(x=>x.Title)
</h2>
@if (!string.IsNullOrEmpty(Model.Subtitle) || Html.ViewContext.IsPreviewMode())
{
<p class="promoBlockTitleSub" @Html.EditAttributes(x=>x.Subtitle)>
@Html.DisplayFor(x=>x.Subtitle)
</p>
}
@if (!string.IsNullOrEmpty(Model.Summary) || Html.ViewContext.IsPreviewMode())
{
<p class="promoBlockSummary" @Html.EditAttributes(x=>x.Summary)>
@Html.DisplayFor(x=>x.Summary)
</p>
}
@if (Model.Link != null || Html.ViewContext.IsPreviewMode())
{
var href = "/";
if (Model.Link is {Href: { } })
{
href = Model.Link.Href;
}
<div class="promoBlockCta" @Html.EditAttributes(x=>x.Link)>
<a href="@Url.ContentUrl(@href)">
<svg class="icon">
<use href="/static/images/svg.svg#svg-triangle" />
</svg>
<span class="text">@Html.DisplayFor(x=>x.Link.Text)</span>
</a>
</div>
}
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment