I am using profile2 module for my User profiles.
Now breadcrumbs on user profile pages are:
Home > Username
I need breadcrumbs to be like this:
Home > Custom page > Custom profile2 field
How can I change it? Thanks for your replies.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI am using profile2 module for my User profiles.
Now breadcrumbs on user profile pages are:
Home > Username
I need breadcrumbs to be like this:
Home > Custom page > Custom profile2 field
How can I change it? Thanks for your replies.
In Drupal 7 you can use MYTHEME_breadcrumb function in template.php file, if you don't want to use any contributed modules.
/**
* Preprocess function to customizing the breadcrumbs
* @param type $variables
* @return string
*/
function MYTHEME_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb']; //get the breadcrumb
if (!empty($breadcrumb)) {
if (arg(0) == 'user' && is_numeric(arg(1))) {//Check your condition based on your requirement for user profile
$breadcrumb[] = l('Custom page text', 'Custom page link');
$breadcrumb[] = t('Custom profile2 field text');
//$breadcrumb[] = l('Custom profile2 field text', 'Custom profile2 field link');//if you want link use this
}
$output .= '<nav class="breadcrumb">' . implode(' » ', $breadcrumb) . '</nav>';
return $output;
}
}
You can use Path Breadcrumbs module. This module helps you to create breadcrumbs for any page with any selection rules and load any entity from the URL.
If this module is not satisfy your requirements, then visit Comparison of Breadcrumb Customizing modules to get more information.
Answer similar to https://drupal.stackexchange.com/a/106057/2974, using Crumbs.
After installing the module:
admin/structure/crumbs/entity-parent/user
, and specify the views page as the parent path for 'authenticated user' (this will cover other roles too, because every user is authenticated).admin/structure/menu
, edit the main menu (or another menu), create an item that links to the views page, and give it a title like "List of users". (*)admin/structure/crumbs
, make sure that the menu.link_title.main-menu
and menu.hierarchy.main-menu
are enabled. Or just enable menu.*
.admin/structure/crumbs/debug
.EDIT: This might not get you the modified title for the last breadcrumb item. If you want that, you can use hook_crumbs_plugins() or hook_menu_breadcrumb_alter() to change that part. Maybe this should be covered in a separate question, "How to to change the title of a breadcrumb item in Crumbs programmatically?".
Note: It could be that in your particular case, Path breadcrumbs is the easier option, as it allows to do all via the UI. Crumbs might improve on that in the future, but for now it is what it is.
You can use yourtheme_breadcrumb hook to change breadcrumb for specific use case. Look at https://api.drupal.org/api/drupal/includes!theme.inc/function/theme_breadcrumb/7