Kooboo View - Menu.BreadCrumb

This is the code to my BreadCrumb trail. Notice I have a few custom steps...
- I want to include the current page in the breadcrumb trail, but as TEXT, not as a LINK.
- For the home page, I want the breadcrumb trail to say "home". For any other page, I don't want that link to show up.
- If the page has a current object, include its Title in the breadcrumb trail. This is used by the Code Library, which uses a single page for both SELECT ALL, and SELECT BY ID (MVC developers may recognize /object and /object/{id}). Since I want to ensure that both the page title ("Code") and the object title appear, I inject the page into the breadcrumb trail. I also then (later on) inject the Title into the breadcrumb trail, but as text, instead of a link.
Language:
C#
Keywords:
Kooboo
Code Snippet

<div class="breadcrumb">

@{

  var BreadcrumbTrail = MenuHelper.Breadcrumb().ToList();

  if (BreadcrumbTrail.Count() > 0)

  {

    BreadcrumbTrail.RemoveAt(0);

  }

 

  // if there is a current object on the page, include the page in the breadcrumbtrail

  //    so that the object's title is shown as the last node

  if (Page_Context.Current.GetFieldValue("Title") != null)

  {

    BreadcrumbTrail.Add(MenuHelper.Current());

  }

}

@foreach (var item in BreadcrumbTrail)

{

  if (item.Navigation.Show)

  {

    @Html.FrontHtml().PageLink(item.LinkText, item.FullName)

    @: &gt;

  }

}

@(Page_Context.Current.GetFieldValue("Title") ?? MenuHelper.Current().Name)

</div>

Example
@Html.FrontHtml().RenderView("Menu.BreadCrumb",ViewData)

Created 2012-02-01
comments powered by Disqus
Login