Customizing breadcrumb in sharepoint publishing site with variations

牧云@^-^@ 提交于 2019-12-09 18:34:01

问题


I have a Sharepoint publishing site with variations. The breadcrumb by default shows this:

Variation Root > English Site > Some Page What I want to display is: "Home" > Some Page, where Home points to the English site root.

Is there a way to achieve this withouth creating a custom server control to do that?


回答1:


If you know the exact number of levels you can use a SiteMapPath like:

<asp:SiteMapPath runat="server" ParentLevelsDisplayed="1" />

Otherwise the SiteMapPath always goes direcly agains the SiteMapProvider currently in use and you can probably hook into the rendering of the SiteMapPath a do a check, like:

protected void SiteMapPath_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
{
    if (e.Item.ItemType == SiteMapNodeItemType.Root ||         
       (e.Item.ItemType == SiteMapNodeItemType.PathSeparator && 
        e.Item.ItemIndex == 1))
    {
        e.Item.Visible = false;
    }
}

that will make you SiteMapPath not showing the rootnode (and the first separator).

and if would like your node to display "Home" you can bind against another value, something like:

<asp:SiteMapPath ID="siteMapPath" runat="server"
    Pathseparator="/"
    OnItemCreated="SiteMapPath_ItemCreated">

<NodeTemplate>
    <a href='<%# Eval("url") %>'><%# Eval("description") %></a>
</NodeTemplate>

<CurrentNodeTemplate>
    <%# Eval("title") %>
</CurrentNodeTemplate>    

</asp:SiteMapPath>

if description has a value of "Home" that will be shown.




回答2:


Just recently I have created a couple of new menu controls which address this issue. My controls accept the custom ~Variation/ token as the StartingNode so that you can create a breadcrumb that starts with the home of your variation rather than the root of your Site Collection. You can find more information @ http://blog.mastykarz.nl/templates-based-menu-control-sharepoint/



来源:https://stackoverflow.com/questions/1002057/customizing-breadcrumb-in-sharepoint-publishing-site-with-variations

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