1

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

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

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

1 回答 1

2

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

菜单项类型的标志在includes/menu.inc. 在那里我们可以看到标志位是从andMENU_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

于 2019-01-20T13:16:06.063 回答