I would like to hide the path to sub menu item which is shown in the breadcrumb once you request a page by clicking the sub menu.
Here is the code I am using to create a menu item and three sub menu items:
$items['what-to-expect'] = array(
'title' => t('What To Expect'),
'page callback' => 'pvmf_layout_what_to_expect',
'access arguments' => array('access content'),
'menu_name' => 'main-menu',
'type' => MENU_NORMAL_ITEM,
'weight' => 1,
'expanded' => TRUE
);
$items['what-to-expect/0'] = array(
'title' => t('Local Event'),
'page callback' => 'pvmf_layout_what_to_expect_0',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'weight' => 0
);
$items['what-to-expect/1'] = array(
'title' => t('Online Event'),
'page callback' => 'pvmf_layout_what_to_expect_1',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'weight' => 1
);
$items['what-to-expect/2'] = array(
'title' => t('ONE Presenters'),
'page callback' => 'pvmf_layout_what_to_expect_2',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'weight' => 2
);
After I change the type
in definition here is the code I am getting:
$items['what-to-expect'] = array(
'title' => t('What To Expect'),
'page callback' => 'pvmf_layout_what_to_expect',
'access arguments' => array('access content'),
'menu_name' => 'main-menu',
'type' => MENU_VISIBLE_IN_TREE,
'weight' => 1,
'expanded' => TRUE
);
$items['what-to-expect/0'] = array(
'title' => t('Local Event'),
'page callback' => 'pvmf_layout_what_to_expect_0',
'access arguments' => array('access content'),
'type' => MENU_VISIBLE_IN_TREE,
'weight' => 0
);
$items['what-to-expect/1'] = array(
'title' => t('Online Event'),
'page callback' => 'pvmf_layout_what_to_expect_1',
'access arguments' => array('access content'),
'type' => MENU_VISIBLE_IN_TREE,
'weight' => 1
);
$items['what-to-expect/2'] = array(
'title' => t('ONE Presenters'),
'page callback' => 'pvmf_layout_what_to_expect_2',
'access arguments' => array('access content'),
'type' => MENU_VISIBLE_IN_TREE,
'weight' => 2
);
But breadcrumbs still continue to show. I tried to clear the cache by going to Configuration
-> Performance
, but it did not help. What may I miss here?
I checked that menu.inc
actually contains:
/**
* Menu type -- A "normal" menu item that's shown in menu and breadcrumbs.
*
* Normal menu items show up in the menu tree and can be moved/hidden by
* the administrator. Use this for most menu items. It is the default value if
* no menu item type is specified.
*/
define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
Use type => MENU_VISIBLE_IN_TREE
in sub menu items definition so that they are visible only in the menu, not in the breadcrumb.
The flags for the menu item types are defined in includes/menu.inc
. There we can see that the MENU_NORMAL_ITEM
flag takes its bits from the bitwise OR operation of MENU_VISIBLE_IN_TREE
and MENU_VISIBLE_IN_BREADCRUMB
:
/**
* Menu type -- A "normal" menu item that's shown in menu and breadcrumbs.
*
* Normal menu items show up in the menu tree and can be moved/hidden by
* the administrator. Use this for most menu items. It is the default value if
* no menu item type is specified.
*/
define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
That means the flag for a MENU_NORMAL_ITEM
not showing in the breadcrumb is MENU_VISIBLE_IN_TREE
.