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.

| improve this question | | | | |
  • What is going to be the url of "custom page" and "custom profile2 field" ? Is "custom page" a static url, or does it change per user? – donquixote Mar 9 '14 at 17:11
  • Custom page url is View page. And custom profile2 field is without url (it would be the same like Page title, which I managed to change in template). – user2171413 Mar 9 '14 at 17:34
  • i don't really get it. what page/path are you visiting where you want to see the breadcrumb you describe? – donquixote Mar 9 '14 at 17:50
  • I am on user profile... so path alias of users/id. Profile2 content is on user profile page. – user2171413 Mar 9 '14 at 17:55
  • ok, so what has profile2 to do with it? – donquixote Mar 9 '14 at 17:55

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;
| improve this answer | | | | |
  • Thanks, it workds. But how can I get the Custom profile2 field in this function? – user2171413 Mar 11 '14 at 12:35
  • You can use profile2_load_by_user API to get the custom Profile2 fields – inizio Mar 24 '14 at 6:52

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.

| improve this answer | | | | |

Answer similar to https://drupal.stackexchange.com/a/106057/2974, using Crumbs.

After installing the module:

  1. Go to 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).
  2. On 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". (*)
  3. On admin/structure/crumbs, make sure that the menu.link_title.main-menu and menu.hierarchy.main-menu are enabled. Or just enable menu.*.
    (enabling means to move those lines up into the "Enabled" section with drag+drop)
  4. To see what going on behind the scenes, you can visit 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.

| improve this answer | | | | |
  • Hm, thanks, but I can't use Crumbs. It breaks all my settings from custom breadcrumbs and I can't make it work with Crumbs. – user2171413 Mar 9 '14 at 18:25
  • If you already use custom breadcrumbs, then I think it is easier to switch to path breadcrumbs from there, instead of switching to Crumbs. – donquixote Mar 9 '14 at 18:31
  • But even if you don't end up using it, I am still interested in feedback about stuff that cannot be done with Crumbs :) – donquixote Mar 9 '14 at 18:33
  • Crumbs look really interesting, but now I don't have time to learnt it :/. Custom breadcrumbs module doesn't support profile2. – user2171413 Mar 9 '14 at 20:07

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

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.