Extending SharePoint Breadcrumbs across multiple s

2019-06-08 03:37发布

问题:

I’ve been trying to find a way to extend SharePoint breadcrumbs across multiple site collections, and I’ve been unable to find a way. I can set the portal site connection setting on the site collection to link to its parent site collection. But, that will not show only one parent site collection. Here’s an example of the type of setup I’m looking at creating.

The root site, Intranet, has a managed path called sites. Under sites there is site collection called HR located at /sites/hr/. Under HR there is another managed path set up called outreach. In outreach there is a site collection called Recruiting located at /sites/hr/outreach/recruiting/. Thus when a user is in the recruiting site, I want them to see Intranet > HR > Recruiting as the breadcrumb trail.

Example as sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
    <siteMapNode title="Intranet" url="http://intranet/Pages/Default.aspx">
    <siteMapNode title="HR" url="http://intranet/sites/hr/default.aspx">
            <siteMapNode title="Recruiting" url="http://inranet/hr/outreach/recruiting/default.aspx"/>
        </siteMapNode>
    </siteMapNode>
</siteMap>

Setting the portal site connection on recruiting I can get HR > Recruiting when you’re in recruiting and setting the portal site connection on HR I can get Intranet > HR when you are in the HR site. I can’t though.

I’ve tried using the SPXmlContentMapProvider to read the sitemap file, but I’ve been unable to get that to display at all when I set that as the SiteMapProvider for the SiteMapPath of GlobalNavigationSiteMap in the default.master. (GlobalNavigationSiteMap is the SiteMapPath that creates the bread crumbs at the top of the site). The same architecture works well however on a generic .NET application, but does not seem to work in SharePoint. I’ve also properly registered the sitemap as a defaultProvider and been able to use it to replace the TopNavigationMenu. (TopNavigationMenu is the global navigation menu/bar of buttons at the top of the default SharePoint layout).

Is there a way to actually build this functionality into SharePoint?

回答1:

Since you are implementing a custom masterpage (or customizing the default one), why not replace the breadcrumb control with your own? Or make a custom sitemap provider if you need to combine your sitemap with Sharepoint's generated map.



回答2:

I've thought a lot about why you can't use SPXmlContentMapProvider and I think it comes down to how SharePoint renders and uses managed paths. My theory is this:

All of the site collection locations in SharePoint are managed paths. Since the content is really stored in the database, and while IIS presents the information like it's in a folder, the pages aren't located in folders. Instead the location is somewhere in the "ether" of SharePoint and whatever location SPXmlContentMapProvider see's itself being in, it's somewhere else then the entries in the xml file. Now the Request.Url does know where you are, but that information does not appear to being presented to the SPXmlContentMapProvider.

I have also come up with a work around for the problem. You could manually edit the master page for each site collection to stick the breadcrumb trail for that site collection in front of the GlobalNavigationSiteMap. Thus, each site collection with this navigational requirement would then need to have it's own custom master page. It's an ugly, brute force way of doing things that I have no intention of implementing. It would work, but would be a maintenance nightmare.