I created a panel page using the Panels module, Contact list at the path messages/contact-list.

The Privatemsg module causes several tabs (Inbox, Sent messages, All messages) to be displayed across the top of pages with path messages. I am attempting to add an additional tab that links to my Panels page, Contact list.

Based on the code in privatemsg.module for the "Sent messages" tab:

  $items['messages/sent'] = array(
    'title'            => 'Sent messages',
    'page callback'    => 'privatemsg_list_page',
    'page arguments'   => array('sent'),
    'file'             => 'privatemsg.pages.inc',
    'file path'        => drupal_get_path('module', 'privatemsg'),
    'access callback'  => 'privatemsg_user_access',
    'type'             => MENU_LOCAL_TASK,
    'weight'           => -12,
    'menu_name'        => 'user-menu',

I added this code to hook_menu() in a custom module:

  $items['messages/contact-list'] = array(
    'title'            => 'Contact List',
    'page callback'    => 'drupal_goto',
    'page arguments'    => array('messages/contact-list'),
    'access callback'  => 'privatemsg_user_access',
    'access arguments' => array('read privatemsg'),
    'type'             => MENU_LOCAL_TASK,
    'weight'           => 10,
    'menu_name'        => 'user-menu',

However, although this produces no errors, even after clearing the cache multiple times no tab appears anywhere. I tried moving the code from my custom module into the privatemsg module to no effect. I've looked at the documentation for hook_menu() but it still isn't clear to me what I'm doing wrong.

  • 1
    not including return $items; was one thing that caused me to face this problem many times :) and I've seen better and more experienced people than me do this too, so I'd suggest that its worth a check, also suggest checking if there is an entry for messages/contact-list in the menu_router table with the respective arguments to gain some insight. – optimusprime619 Apr 19 '13 at 6:58
  • I did include return $items; there is an entry in the menu_router table with ctools_access_menu as the access callback and page_manager_page_execute as the page callback. I don't really understand what that means though. – Patrick Kenny Apr 19 '13 at 8:41

The reason for your problem is that page manager has already defined a menu entry for that path. Just as well, because the menu item you have created would cause an infinite chain of redirection. You would need to change the path for your panels page to be something different in order for the redirection to work.

But you can simply remove your menu entry altogether and use page manager to define the menu item for the page as a tab under Settings -> Menu. You shouldn't need any extra code to do that.

  • I could've swore there was a reason I avoided using the Panels UI, but I was able to do it this way without trouble. Thanks! – Patrick Kenny Apr 19 '13 at 11:29

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.