4

在我的模块文件中,我创建了一个新菜单项

function xmlproject_menu() 
{
  $items = array();

  //more items here

  $items['system/xml/cfa/initialize/%/%/%/%/%'] = array(
    'page callback' => 'xmlproject_initialize_cf',
    'page arguments' => array(4, 5, 6, 7, 8,),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function xmlproject_initialize_cf($session_id, $cart_id, $pid, $rid, $partner_id)
{
  //some code here
}

我尝试去 admin/build/modules、devel/menu/reset 和 admin/settings/performance 来清除缓存。我可以看到数据库中的菜单项(menu_router)。 在此处输入图像描述

当我转到http://example.com/system/xml/cfa/initialize/1/2/3/4/5时,我收到“找不到页面”。

4

3 回答 3

1

正如您在number_part包含路由器路径中的部件数的数据库列中看到的,设置为 7(最大可用部分),但您的菜单回调部分为 9。这比 drupal 6 中可用的 MENU_MAX_PARTS 多 这就是为什么只需减小菜单项的大小就可以了Page not found 。例如:

$items['initialize/%/%/%/%/%'] = array(
    'page callback' => 'xmlproject_initialize_cf',
    'page arguments' => array(4, 5, 6, 7, 8),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
 );
于 2015-08-26T11:24:30.023 回答
1

您的代码似乎没有任何问题。只是好奇,为什么您将数组的最后一个元素保留为“空”(数字 8 后的逗号)

'page arguments' => array(4, 5, 6, 7, 8,),

此外,数组中还有额外的空项(MENU_CALLBACK 后的逗号)

'type' => MENU_CALLBACK,
于 2015-08-25T17:09:25.417 回答
1

你的代码看起来很花哨,但我想你的页面回调“xmlproject_initialize_cf”实际上应该返回一些东西。

尝试这个:

function xmlproject_initialize_cf($session_id, $cart_id, $pid, $rid, $partner_id)
{
  // Your Code
  return 'Hello world!';
}

模块名称是“xmlproject”吗?

于 2015-08-25T14:44:22.543 回答