Add custom breadcrum

I have to add a custom breadcrumb to my twitter page (Share >> Members >> User >> Recent tweets) . for this we need to add a the following code in templete.php. We will user your_theme_preprocess_breadcrumb() function.

function your_theme_preprocess_breadcrumb(&$variables) {
// Replace the default search api breadcrumb.
foreach ($variables['breadcrumb'] as $key => $breadcrumb) {
  $strip_breadcrumb = strip_tags($breadcrumb);
if ($strip_breadcrumb == '[all items]') {
  $variables['breadcrumb'][$key] = t('All Content');
}
}
if ((arg(0) == "user") && (is_numeric(arg(1)))) {
  $user = profile2_load_by_user(arg(1));
  $user_name = $user['main']->field_ekn_name['und'][0]['value'];
  $user_uid = $user['main']->uid;
  //echo ""; print_r($user_uid);
  //echo ""; print_r($user);die();
  $variables['breadcrumb'][1] = l('Share', 'share');
  $variables['breadcrumb'][2] = l('Members', 'share/members');
  $variables['breadcrumb'][3] = t($user_name);
if ((arg(0) == "user") && (is_numeric(arg(1))) && arg(2) == 'tweets') {
  $variables['breadcrumb'][3] = l(t($user_name),'share/members/' .$user_uid);
  $variables['breadcrumb'][4] = t('Recent Tweets');
  }
 } 
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s