Breadcrumbs in custom pages/widget

amaneet
Kilo Contributor

Hi SNC,

Would like to know how to add breadcrumbs in custom pages. We have 2 pages mypage1 and mypage2

page2 is opened when we click on page1

So we want home->page1->page2

Thanks

3 REPLIES 3

ChrisBurks
Mega Sage

Does the OOB breadcrumb widget not work when you add it to the custom page?


amaneet
Kilo Contributor

no


By no, do you mean that it doesn't display anything or what it displays is not what's expected. Or are there any errors?



The breadcrumbs widget itself is really simple. It listens for a broadcast (sp.update.breadcrumbs) of an object to display the crumbs. The object should contain two properties "url" and "label". Url is going to be the url for the href attribute and label's value will be used for the text that's displayed in the breadcrumb.



Knowing that, you should be able to pull the breadcrumb widget on your custom page. Then in any other widget on the same page in the client controller script broadcast sp.update.breadcrumbs with the needed data. Something similar to this:


$rootScope.$broadcast('sp.update.breadcrumbs', [{url: 'sp?id=some_cool_page', label: 'My Cool Page'}])