Hello,
we are having an issue creating a button block. When we use the block on a page, it renders perfectly fine. However, it does not display as a button when used with another block, it just shows the name of the block as text. The view should render it as a button, but it isnt working on blocks for whatever reason. Does anyone know what could cause this block to render differently on blocks vs pages?
Our button model:
using CapCom.Epi.Core.Models.Base;
using EPiServer;
using EPiServer.DataAbstraction;
using System.ComponentModel.DataAnnotations;
namespace CapCom.Epi.Core.Models.Blocks
{
/// <summary>
/// Used to insert a link which is styled as a button
/// </summary>
[SiteContentType(GUID = "426CF12F-1F01-4EA0-922F-0778314DDAF0")]
[SiteImageUrl]
public class ButtonBlock : BaseBlock
{
[Display(Order = 1, GroupName = SystemTabNames.Content)]
[Required]
public virtual string ButtonText { get; set; }
[Display(Order = 2, GroupName = SystemTabNames.Content)]
[Required]
public virtual Url ButtonLink { get; set; }
}
}
Our button view:
@using CapCom.Epi.Core.Models.Blocks
@using EPiServer.ServiceLocation
@model ButtonBlock
@{
var urlHelper = ServiceLocator.Current.GetInstance<UrlHelper>();
var url = urlHelper.ContentUrl(Model.ButtonLink);
}<p class="text-center"><a href="@url" class="btn btn-copper">@Model.ButtonText <i class="fa fa-chevron-right" aria-hidden="true"></i></a></p>