I have a long list of menu items so i'll cut it short here:

$items['admin/skyview'] = array(
    'title' => 'Skyview Main Page',
    'type' => MENU_NORMAL_ITEM,
    'access callback' => TRUE,
    'page callback' => 'skyview_main_page',
$items['admin/skyview/tab1'] = array(
    'title' => 'Skyview',
    'access callback' => TRUE,
    'weight' => 0,
$items['admin/skyview/tab5'] = array(
    'title' => 'Sites',
    'type' => MENU_LOCAL_TASK,
    'access callback' => TRUE,
    'weight' => 4,
    'page callback' => 'skyview_sites',

But my question is how do I programmatically get the title of 'Sites' for tab5? When I use menu_get_active_title it returns 'Skyview Main Page' instead.

I've looked through phpstorm for what options it gives me, but I really don't find anything to get the title of a menu local task, however I noticed this can be done in D8 but can it be done in D7?

  • FYI I don’t know if this is testcode or not, but you’ll want to fix those access callbacks. – Kevin Dec 14 '18 at 19:09
  • What's wrong with them? – Shawn Dec 14 '18 at 19:12
  • It basically says any user can access this path, the only mitigating access check is the one done against admin/. IMO you want to do some sort of custom permission check here. – Kevin Dec 14 '18 at 20:26

I figured out how to finally get the title.

I was using dpm(menu_get_item()); which listed an array, but I had no idea how to access it. I just had to turn it into a variable to hold that data, then I could access it!

$db_site = menu_get_item();
$db_site = $db_site['title'];

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.