不要在面包屑中显示子菜单项的路径

Do not show path to sub menu items in breadcrumb

我想隐藏子菜单项的路径,一旦您通过单击子菜单请求页面,它就会显示在面包屑中。

这是我用来创建一个菜单项和三个子菜单项的代码:

    $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
      );

这是我看到的:

在我更改定义中的 type 后,我得到的代码是:

$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
  );

但面包屑仍然继续显示。我试图通过转到 Configuration -> Performance 来清除缓存,但没有帮助。我在这里可能会错过什么?

我检查过 menu.inc 实际上包含:

/**
 * 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);

在子菜单项定义中使用 type => MENU_VISIBLE_IN_TREE,以便它们仅在菜单中可见,而不在面包屑中可见。

菜单项类型的标志在 includes/menu.inc 中定义。在那里我们可以看到 MENU_NORMAL_ITEM 标志从 MENU_VISIBLE_IN_TREEMENU_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);

这意味着 MENU_NORMAL_ITEM 未显示在面包屑中的标志是 MENU_VISIBLE_IN_TREE