MvcSiteMapProvider No Separetor

扶醉桌前 提交于 2019-12-11 12:04:31

问题


I don't want the MvcSiteMapProvider to display the ">" separtor betweent the breadcrumbs.

Example: Home > Contact What I want: Home Contact (a separetor between the breadcrumbs is added with CSS).

I dodn't found any property called "separetor" to set this in the docu (https://github.com/maartenba/MvcSiteMapProvider/wiki).


回答1:


MvcSiteMapProvider uses templated HTML helpers. You can edit the templates any way you want to change the output HTML to meet your needs (including the separator character).

For the SiteMapPath, simply edit the template at /Views/Shared/DisplayTemplates/SiteMapPathHelperModel.cshtml as follows.

Default

@model MvcSiteMapProvider.Web.Html.Models.SiteMapPathHelperModel
@using System.Web.Mvc.Html
@using System.Linq
@using MvcSiteMapProvider.Web.Html.Models

@foreach (var node in Model) { 
    @Html.DisplayFor(m => node);

    if (node != Model.Last()) {
        <text> &gt; </text>
    }
}

Edit

@model MvcSiteMapProvider.Web.Html.Models.SiteMapPathHelperModel
@using System.Web.Mvc.Html
@using System.Linq
@using MvcSiteMapProvider.Web.Html.Models

@foreach (var node in Model) { 
    @Html.DisplayFor(m => node);

    if (node != Model.Last()) {
        <text> </text>
    }
}



回答2:


Bootstrap has a separator for this. <span class="divider">

Check out this link.

https://joeylicc.wordpress.com/2013/07/08/asp-net-mvc-sitemappath-using-site-map-provider-bootstrap-breadcrumbs/



来源:https://stackoverflow.com/questions/31073952/mvcsitemapprovider-no-separetor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!