Adding Custom Breadcrumbs to Views Pages

Recently I needed to add custom breadcrumbs to views 2 generated pages. Now we were using excellent custom_breadcrumbs 1.x to add custom breadcrumbs on site. At that time I discovered that 1.x version of custom_breadcrumbs do not support views generated pages and 2.x version of module (which supports views) is not production stable. So I came up with this solution to create custom breadcrumbs for views pages:

Lets say we have a page view with structure
—Team (menu item)
   |—Featured 1 (tab-default)
   |—Featured 2 (tab)
   |—Featured 3 (tab)

Now instead of having a breadcrumb like “Home ›” OR “Home › Team we need  something like “Home › Our Team › Featured 1” for default tab. To accomplish this we need to add following php code in header section of view page with php filter enabled.

global $base_url;
[] = l('Home', null);
$breadcrumb[] .= l('Our Team', 'team');
$breadcrumb[] .= l(drupal_get_title(), $base_url.$_SERVER['REQUEST_URI']);

Now this custom php will set new breadcrumb of page as:

2017-03-31T06:20:15+00:00 Categories: Development, How-To|

About the Author: