开发者

hook_menu() - an unexpected behaviour (longer path issue)

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/开发者_Go百科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?


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.

$items['webtv/block/%/playlist/edit/%/filter/%']

to

$items['webtv/block/%/playlist/edit/%/%']

and

$items['webtv/block/%/playlist/edit/%/filter/new']

to

$items['webtv/block/%/playlist/edit/%/new']
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜