1

Not sure how to word it and I am sure plenty of other people have run into this problem, so I apologize in advance.

I have the following code:

 function content_type_message_menu() {
  $items = array();

  $items['admin/config/content/authoring/messages'] = array(
    'title' => 'Messages',
    'description' => 'Configure what messages are displayed for the differing content types and who has permission to see them.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('content_type_message'),
    'access arguments' => array('administer content type messages'),
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/config/content/authoring/messages/settings'] = array(
    'title' => 'Settings',
    'description' => 'Configure who has permission to see them.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('content_type_message_roles_form'),
    'access arguments' => array('administer content type messages'),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

The second page I can access when I go to 'admin/config/content/authoring/messages/settings' but I do not see a tab on the first page ('admin/config/content/authoring/messages') to go to this second page. Anyone know what I might be doing wrong?

1

Drupal doesn't show tabs when there is just a tab defined or visible for the currently logged-in user (which includes the case users don't have the permission to see other defined tabs).
If you look at what Drupal does, for each node there is node/%node/view and node/%node/edit; when users don't have the permission to edit a node, they don't see any tab, in the node page.

See the following screenshot, taken from drupal.org at https://www.drupal.org/node/5, using an account with the permission to edit the node.

screenshot

You see the View, Edit, Outline, and Revisions tabs.

Compare it with the screenshot taken using an anonymous user account, for the same page.

screenshot

You don't see any tab, but the screenshot is for the View tab. In fact, if you try accessing https://www.drupal.org/node/5/view as anonymous user, you would see the same as in the last screenshot.

  • When I get enough of a reputation you are getting a arrow up for this. You are awesome. Been sitting here for like 2hrs+ asking myself WTF! THANK YOU!!! – Daedalus Nov 10 '15 at 17:22
0

So it seems I was getting this issue AGAIN when starting up a brand new project. So I tried something unconventional. I just created a third page...

$pages['admin/config/content/messages/roles1'] = array(
    'title' => 'Roles that can see Messages',
    'description' => 'Set roles that can see the messages',
    'page callback' => 'what',
    'access arguments' => array('Administer content types '),
    'type' => MENU_IS_LOCAL_TASK,
  );

... THEN it like for some reason hit drupal upside the head and picked up the third page and the 2nd page and made the appropriate tabs on the first page.

So the answer it seems is, if you have been clearing cache and you know what you are doing is 100% correct (which was my case) then just make another page, clear that cache and watch it pickup the page you intended for.

  • New issue though, if you remove the 3rd page and clear cache, both tabs disappear. If I remove the 2nd page and clear cache, then again both tabs disappear. This must be a bug. – Daedalus Nov 10 '15 at 16:42

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.