views:

35

answers:

2

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?

A: 

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']
Shoaib
+4  A: 

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.

Henrik Opel
Good catch! Unfortunately, there isn't a reference to this limitation in the documentation page for `hook_menu()`, which I think is the first place one would check to know some details more about how to implement menu callbacks.
kiamlaluno
Thanks buddy, a new thing for me.And it has been extended to 9 in Drupal 7.
Shoaib

related questions