Showing posts with label SharePoint Online. Show all posts
Showing posts with label SharePoint Online. Show all posts

Saturday, October 12, 2013

Breadcrumb in SharePoint 2013

Estruyf has an excellent post on using the Suite Bar for Breadcrumb. In my case I needed it for my SharePoint Online (O365) project and I was using Starter Master Pages by Randy Drisgrill.

The below are some tweaks that I did to get it working:

The below control in the master page generates the Ribbon and the Suite Bar
<PublishingRibbon:PublishingRibbon runat="server" />

With limited support for PowerShell in SharePoint Online, I instead used Estruvf's JS code and used it my MasterPage. I updated the below lines:

From:
if (_spPageContextInfo.pageListId.toUpperCase() == ctx.listName.toUpperCase()) {

To:
if (_spPageContextInfo.pageListId.toUpperCase() == ctx.listName.toUpperCase() || _spPageContextInfo.pageListId.substring(1, _spPageContextInfo.pageListId.length - 1).toUpperCase() == ctx.listName.toUpperCase()) {

to show breadcrumbs for Calendars.

From:
this.elm.innerHTML = this.breadcrumb;

to:
For SharePoint Online: $('#suiteBrandingBox').text(this.breadcrumb);  
For SharePoint 2013:   $('#ms-core-brandingText').text(this.breadcrumb);


The suiteBrandingBox is generated by the PublishingRibbon control, 
and lastly I didn't need to show the Home site, I included the following in the onQuerySuccess function (parentWeb)
if (this.parentweb.get_serverRelativeUrl() != "/")

HTH