Customizing breadcrumb in sharepoint publishing site with variations

Emad Gabriel picture Emad Gabriel · Jun 16, 2009 · Viewed 7.3k times · Source

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?

Answer

Johan Leino picture Johan Leino · Jun 16, 2009

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.