如何在Sitecore MVC链接字段中添加引导程序图标



我有以下HTML代码:

<a data-toggle="dropdown">Associate Sites<i class="fa fa-angle-down"></i></a>

使用Sitecore MVC字段:

 @Html.Sitecore().BeginField("Link Field", new { @data_toggle = "dropdown" })
 @Html.Sitecore().Field("Destination URL", item.Item, new { @data_toggle = "dropdown" })<i class="fa fa-angle-down"></i>
 @Html.Sitecore().EndField()

结果:

<a href="/en" data_toggle="dropdown">Associate Sites</a> <i class="fa fa-angle-down"></i> 

预期结果:

<a href="/en" data_toggle="dropdown">Associate Sites<i class="fa fa-angle-down"></i></a>  

请帮助我,我如何才能将引导程序图标集成到Sitecore字段中。

您只需要以下内容:

@Html.Sitecore().BeginField("Destination URL", item.Item, new { @data_toggle = "dropdown" })
    <i class="fa fa-angle-down"></i>
@Html.Sitecore().EndField()

这将输出以下HTML:

<a href="/my-url" data_toggle="dropdown">My Page Name
    <i class="fa fa-angle-down"></i>
</a>

由于您在解决方案中明显使用了Glass Mapper,因此您应该使用此功能,而不是使用Sitecore Field助手和"魔术串"

@Html.Glass().Editable(Model, x => x.DestinationURL, 
    string.Format("<a href="{0}" data-toggle="dropdown">{1}<i class="fa fa-angle-down"></i></a>", x.DestinationURL.Url, x.DestinationURL.Text))

最新更新