Last active
August 29, 2015 14:21
-
-
Save RyanABailey/4039f100f60d99bd5b66 to your computer and use it in GitHub Desktop.
Sitecore breadcrumbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Item currentItem = Sitecore.Context.Item; // Current sitecore item | |
| BreadCrumbs.Current = currentItem.Fields["Title"].ToString(); // set current items title on breadcrumb object | |
| currentItem = currentItem.Parent; // go to parent of current item | |
| while (currentItem.ID != new ID(Items.ContentRootItem)) | |
| { | |
| // add parent item to breadcrumb object (a list of parent items) | |
| BreadCrumbs.Parents.Add(new Common.MenuItem | |
| { | |
| Link = Sitecore.Links.LinkManager.GetItemUrl(currentItem), | |
| Text = currentItem.Fields["Title"].ToString() | |
| }); | |
| currentItem = currentItem.Parent; // get parent of current item | |
| } | |
| BreadCrumbs.Parents.Reverse(); // reverse order of parents to get in correct order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment