drupal-6 - Drupal 6 : Adding sub menu items on a menu item?

标签 drupal-6

我有一个钩子(Hook):

function node_field_link_menu() 
{
    $items['order_food'] = array(
        'title' => 'Products',
        'page callback' => 'node_field_link_products_page',
        'access callback' => TRUE,
        'menu_name' => 'primary-links',  
        'type' => MENU_NORMAL_ITEM,
    );
  return $items;
}

这给了我我的菜单项,我很满意。问题是,我想要这个菜单项下的项目,所以我最终得到:
- Products
   - Product 1
   - Product 2
   - Product 3
   - Product 4

我读到您可以使用“plid”,但问题是,在这种情况下,我不知道 PLID 是什么,因为我刚刚创建了父级。所以我不能这样做:
function node_field_link_menu() 
{
    $items['order_food/procuct1'] = array(
        'title' => 'Product 1',
        'page callback' => 'node_field_link_products_page1',
        'access callback' => TRUE,
        'menu_name' => 'primary-links',  
        'type' => MENU_NORMAL_ITEM,
        'plid' => XXX?,
    );
  return $items;
}

那么如何在 Drupal 6 中创建的菜单项下方添加另一个菜单项?

最佳答案

你所做的应该在没有'plid'的情况下工作。 Drupal 识别路径模式并为您完成工作。意思是,如果你有一个“order_food”的路径和一个“order_food/product1”的路径,product1 将是“order_food”的 child 。
创建菜单后,您需要做的就是清除 Drupal 的缓存。

刚刚在一个新的 Drupal 6 实例上尝试过,清除了缓存,我看到它工作:

$items['order_food'] = array(
    'title' => 'Product',
    'page callback' => 'node_field_link_products_page',
    'access callback' => TRUE,
    'menu_name' => 'primary-links',
    'type' => MENU_NORMAL_ITEM,
);
$items['order_food/product1'] = array(
    'title' => 'Product1',
    'page callback' => 'node_field_link_products_page1',
    'access callback' => TRUE,
    'menu_name' => 'primary-links',
    'type' => MENU_NORMAL_ITEM,
);

打开“admin/build/menu-customize/primary-links”的 URL 将显示 Product1 作为 Product 的子级。

关于drupal-6 - Drupal 6 : Adding sub menu items on a menu item?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33646421/

相关文章:

Drupal 6 - 添加分类术语后重定向

drupal - 如何检查用户是否正在访问 drupal 中的特定模块

drupal - 用于过滤结果的搜索 Hook ?

drupal - 对用户权限的更改不保存

drupal - 根据域按分类术语过滤 Drupal View (显示在面板中)

php - 使用 API 将模块的数据暴露给 Views2

javascript - 如何在 Drupal 6 中关闭手动创建并打开的 ctools 模式?

drupal-6 - 如何在drupal View 中有条件地隐藏字段?

Drupal View 公开过滤器: Taxonomy Select List?

drupal - 在 Drupal 6 的 <head> 中加载外部脚本