0

I want to change Title and breadcrumb for user pages to username to My Account. I don't want to user drupal_set_title or drupal_set_breadcrumb bcoz its in lots of pages

I saw below code in user core module

  $items['user/%user'] = array(
        'title' => 'My account',
        'title callback' => 'user_page_title',
        'title arguments' => array(1),
        'page callback' => 'user_view_page',
        'page arguments' => array(1),
        'access callback' => 'user_view_access',
        'access arguments' => array(1),
        // By assigning a different menu name, this item (and all registered child
        // paths) are no longer considered as children of 'user'. When accessing the
        // user account pages, the preferred menu link that is used to build the
        // active trail (breadcrumb) will be found in this menu (unless there is
        // more specific link), so the link to 'user' will not be in the breadcrumb.
        'menu_name' => 'navigation',
      );

/**
 * Menu item title callback - use the user name.
 */
function user_page_title($account) {
  return is_object($account) ? format_username($account) : '';
}

User menu is calling title callback function and set the user name in that callback function. So i have tried hook_menu_alter to change title callback of user menu but it is not working

My Code

function health_portal_menu_alter(&$items) { 
  $items['user/%user']['title callback'] = 'health_portal_user_menu_title';
}

function health_portal_user_menu_title() {
  return 'Test';
}

Anybody tell me what is wrong with this code and what i do?

Thanks

3
  • Did you clear the cache after implementing the hook?
    – donquixote
    Commented Nov 21, 2014 at 14:32
  • Yes i had tried with clear cache. but it did not work Commented Nov 24, 2014 at 6:45
  • Ok next thing to check would be if the menu_router database table contains the modified entries. Your code looks correct, so you need to investigate.
    – donquixote
    Commented Nov 24, 2014 at 16:02

1 Answer 1

1

Before trying to implement through code, give a try to these modules:

https://www.drupal.org/project/page_title

https://www.drupal.org/project/custom_breadcrumbs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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