hook_menu() - 意外行为(较长路径问题)
我正在通过 hook_menu (Drupal 6) 初始化多个项目。
...
$items['webtv/block/%/playlist/edit/%'] = array(
...
'page arguments' => array('webtv_playlist_form', 2, 5),
...
);
$items['webtv/block/%/playlist/edit/%/filter/new'] = array(
...
'page arguments' => array('webtv_playlist_param_form', 2, 5),
...
);
$items['webtv/block/%/playlist/edit/%/filter/%'] = array(
...
'page arguments' => array('webtv_playlist_param_form', 2, 5, 7),
...
);
return $items;
第一个条目是父条目,工作正常。以下两个是子条目。最后两个菜单条目仍然无效并重定向到父页面视图。我通过从路径定义中删除第一个通配符“%/”标记来修复它。
意思是:
$items['webtv/block/%/playlist/edit/%/filter/%']
to
$items['webtv/block/playlist/edit/%/filter/%']
和
$items['webtv/block/%/playlist/edit/%/filter/new']
to
$items['webtv/block/playlist/edit/%/filter/new']
请帮助我通过添加通配符来解决我做错了什么?超过两张外卡无效吗?
I am initializing a number of items via hook_menu (Drupal 6)
...
$items['webtv/block/%/playlist/edit/%'] = array(
...
'page arguments' => array('webtv_playlist_form', 2, 5),
...
);
$items['webtv/block/%/playlist/edit/%/filter/new'] = array(
...
'page arguments' => array('webtv_playlist_param_form', 2, 5),
...
);
$items['webtv/block/%/playlist/edit/%/filter/%'] = array(
...
'page arguments' => array('webtv_playlist_param_form', 2, 5, 7),
...
);
return $items;
First entry is a parent entry and works fine. The following two are child entries. These last two menu entries remain invalid and redirects to parent page view. I fixed it with a small modification by eliminating first wild card '%/' mark from the path definitions.
Means:
$items['webtv/block/%/playlist/edit/%/filter/%']
to
$items['webtv/block/playlist/edit/%/filter/%']
and
$items['webtv/block/%/playlist/edit/%/filter/new']
to
$items['webtv/block/playlist/edit/%/filter/new']
Please help me out what I am doing wrong by adding a wild card? Is more than two wild card are invalid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文档中没有充分提及,但可用于 Drupal 菜单回调的路径元素数量有限制 - 请参阅 MENU_MAX_PARTS 常量。
对于 Drupal 6,此限制为 7,您的第二条和第三条路径超出了该限制。您的两个修复都将元素计数减少到七个,这就是它们起作用的原因。
It is not mentioned sufficiently in the documentation, but there is a limit on the number of path elements you can use for a Drupal menu callback - see the MENU_MAX_PARTS constant.
For Drupal 6, this limit is seven, which your second and third path exceeded. Both of your fixes bring the element count down to seven, which is why those work.
正如我提到的,我已经解决了这个问题,没有排除第一个通配符。但我找不到任何逻辑上的理由。
到
和
到
I have fixed the issue without excepting first wild card as I mentioned it. But I could not found any logical reason.
to
and
to