test module:
menu_bug.info

name = Menu bug
core = 7.x

menu_bug.module

// Implements hook_menu().
function menu_bug_menu() {
  $items['test1'] = array(
    'title' => 'Test 1 (this page has a title)',
    'page callback' => 'menu_page_callback',
    'type' => MENU_NORMAL_ITEM,
    'access callback' => TRUE,
  );

  $items['test2'] = array(
    'title' => 'Test 2 (this page does not have a title)',
    'page callback' => 'menu_page_callback',
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
  );

  return $items;
}

function menu_page_callback() {
  return 'HELLO';
}

the test2 page does not have a title. This worked previously..

Comments

effulgentsia’s picture

Possibly related to #907690-55: Breadcrumbs don't work for dynamic paths & local tasks #2. I'm not sure this is really critical, or even a bug in light of that issue, but since it is a change from D6, I'll leave that to others to decide.

chx’s picture

Status: Active » Closed (works as designed)

use MENU_VISIBLE_IN_BREADCRUMB

droplet’s picture

Title: no title on root MENU_CALLBACK pages » Need Docs for MENU_CALLBACK API changes
Component: menu system » documentation
Priority: Critical » Major
Status: Closed (works as designed) » Needs work

I have closed around 5 same issues and I'm also confused about its by design or a bug, need Docs point developer to right way.

Dave Cohen’s picture

It's for sure not how Drupal 6.x behaved.

http://api.drupal.org/api/drupal/modules--system--system.api.php/functio... doesn't mention MENU_VISIBLE_IN_BREADCRUMB at all.

menu.inc refers to MENU_VISIBLE_IN_BREADCRUMB as an "internal menu flag" and not a "menu type".

All reasons to think its a bug, IMHO.

jhodgdon’s picture

Status: Needs work » Closed (works as designed)

We don't document any of the internal menu flags on hook_menu(), just the combinations. For instance, we list MENU_NORMAL_ITEM rather than the flags it's composed of: MENU_VISIBLE_IN_TREE and MENU_VISIBLE_IN_BREADCRUMB.

I think that is the right thing to do. There's a link provided to menu.inc so you can go read about all the other possible constants you could use to compose your own custom combinations if you wanted to, but the choices listed in hook_menu() cover the most common cases.

Regarding MENU_CALLBACK itself, its docblock says:

/**
 * Menu type -- A hidden, internal callback, typically used for API calls.
 *
 * Callbacks simply register a path so that the correct function is fired
 * when the URL is accessed. They do not appear in menus or breadcrumbs.
 */

So I think everything is documented correctly.

jhodgdon’s picture

removing non-standard tag

droplet’s picture

okay. I change title back, more people will search by MENU_CALLBACK + title.

MENU_CALLBACK in D7 is different to D6, not really sure if anyone can find the new change and use MENU_VISIBLE_IN_BREADCRUMB instead..

another bad thing is ......
if you set 'type' => MENU_NORMAL_ITEM first and then change to 'type' => MENU_CALLBACK, whatever you clear cache how many times.... the title still there (the title MENU_NORMAL_ITEM has set)

easy to overlook it (while API doesn't tell which is set title or not)

droplet’s picture

Title: Need Docs for MENU_CALLBACK API changes » no title on root MENU_CALLBACK pages
Dave Cohen’s picture

We don't document... ...the right thing to do.

It's good to be in the know.

jhodgdon’s picture

Dave: You have taken what I said out of context.

If you think this needs more documentation, you can reopen and preferably add a patch showing what you'd like to be documented. The issue queue is a place for productive discussion, so you are free to disagree politely. :)

Dave Cohen’s picture

I apologize. Sometimes online posts come across harsher than intended, and my comment #9 is one of those.

I was bounced from issue to issue before landing here. Its obviously something that a number of users have been surprised by, myself included. I was frustrated to spend time on it.

Anyway, I added a comment to the hook_menu() page on api.drupal.org. Maybe that will save others time.

Hopefully this comes across as polite... I think something documented as "internal", that is how MENU_VISIBLE_IN_BREADCRUMB is described, implies it is for use in Drupal code but not in contrib modules. I wouldn't expect "internal" values to behave the same from one version of Drupal to the next. On the other hand, I would expect the other types to remain the same. I'm curious if there was even a reason behind changing MENU_CALLBACK.

redben’s picture

So, can we use MENU_VISIBLE_IN_BREADCRUMB or not since it is internal ?

droplet’s picture

#12,
you can use it on your module, MENU_VISIBLE_IN_BREADCRUMB is the default value in D6

Dave Cohen’s picture

MENU_VISIBLE_IN_BREADCRUMB is the default value in D6

According the doc, MENU_NORMAL_ITEM is the default in D6, and remains the default in D7. The difference is that MENU_NORMAL_ITEM has changed.

So, can we use MENU_VISIBLE_IN_BREADCRUMB or not since it is internal?

MENU_VISIBLE_IN_BREADCRUMB belongs to a list of "flags for use in the type attribute of menu items". Whereas MENU_NORMAL_ITEM belongs to a list of "menu item types" meaning "item definitions provide one of these constants". Although the documentation is deemed correct, I personally understand why you would ask. My answer: you have to use it, if you want menu items to behave as they did in D6.

droplet’s picture

yeah, right. I should have been a bit more clear on #13. As this thread talk about MENU_CALLBACK

which MENU_CALLBACK in D6 is

define('MENU_CALLBACK', MENU_VISIBLE_IN_BREADCRUMB);

and D7

define('MENU_CALLBACK', 0x0000);

mdshields’s picture

Is there simple documentation that just goes through each scenario:

1. document how to setup a menu that shows up in a navigation with a couple parents and some children, siblings, and sub-child
2. document how to setup a menu that shows up in main menu as siblings
3. document how to setup so that menu does not show up or shows up for specific events.

with propietary software, we need to know what you are thinking when this is created. I understand when this was all created there was so much to think about, but it seems the original thought is lost and now we are all left with millions of posted questions on what to do what where.

mdshields’s picture

I found the source of a lot of confusion with menu hook.

If you make any changes to your menu, only those changes get updated. The remainder of the menu items that were not changed are static in the database. WHich means, if you change a few elements around in your menu, everything will start looking garbled as the identifiers get mixed up since the database menu elements lost their position based on the identifiers that were previously in place.

Drupal needs a way to clear out all menu items whenever a menu hook is updated.

jsenich’s picture

Status: Closed (works as designed) » Active

Is this really intended functionality or is this related to this issue #965272: Items defined with type MENU_CALLBACK show "Home" as a title, which is very clearly a bug?

jsenich’s picture

Status: Active » Closed (fixed)

Dries committed a patch for #965272: Items defined with type MENU_CALLBACK show "Home" as a title which fixes the problem and brings back titles for MENU_CALLBACK items.