Incorrect title displayed

2 replies [Last post]
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11

I am having a problem with the following piece of code:

$items['sts-user/%user'] = array(
'title' => 'STS User Details',
'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('user_profile_form', 1),
'access arguments' => array('administer sts user'),
'theme callback' => 'variable_get',
'theme arguments' => array('admin_theme'),
'file' => '',
'file path' => '/modules/user',
$items['sts-user/%user/default'] = array(
'title' => 'User Details',
'weight' => -10,
$items['sts-user/%user/notes-comms'] = array(
'title' => 'Notes and Communications',
'page callback' => 'sts_user_communications_notes',
'page arguments' => array(1),
'access arguments' => array('administer sts user'),
'type' => MENU_LOCAL_TASK,
'file' => '',
$items['sts-user/%user/courses'] = array(
'title' => 'Courses',
'page callback' => 'sts_user_courses',
'page arguments' => array(1),
'access arguments' => array('administer sts user'),
'type' => MENU_LOCAL_TASK,
'file' => '',

The first (default) item displays correctly with the title "STS Users Details" but the other two have the incorrect title "Home".

Issue 965272 ( seems to address this issue with a patch. It has multiple versions and I cannot apply it. When i look at includes/, it appears that the patch has already been applied. Furthermore, it is marked as being a Drupal 8 issue and closed.

I find these Drupal issues very hard to get my head around and, I appear not to be the only one as the last comment asks if there is a solution?

How can I get my titles to show correctly?

Drave Robber
Last seen: 9 years 6 weeks ago
Joined: 2012-08-07

This might be a little confusing, but 'title' here refers to the title of the tab itself, not the title of the page when the said tab is active.
See, for example, node_menu():

  $items['node/%node/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'node_page_edit',
    'page arguments' => array(1),
    'access callback' => 'node_access',
    'access arguments' => array('update', 1),
    'weight' => 0,
    'type' => MENU_LOCAL_TASK,
    'file' => '',

The tab is named simply 'Edit', but the page callback, node_page_edit(), explicitly sets different (and more infomative) page title:
function node_page_edit($node) {
  $type_name = node_type_get_name($node);
  drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
  return drupal_get_form($node->type . '_node_form', $node);

That's what you have to do, too - use drupal_set_title() in your page callback.

P.S. <code></code> tags rock! ;)

Last seen: 6 years 29 weeks ago
Joined: 2011-06-11

Thanks Drave Robber (I nearly called you Dave!). I'll take a look when the kids are in bed and I can think straight.

Point taken about html tags. I did not realize I could do that.

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.