[drupal-devel] menu path question?
This works: $items[] = array('path' => 'newspaper', 'title' => t('view1'), 'type' => MENU_CALLBACK, 'callback' => 'newspaper_search', 'access' => TRUE); $items[] = array('path' => 'newspaper/search', 'title' => t('Search'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); $items[] = array('path' => 'newspaper/advanced', 'title' => t('Advanced search'), 'type' => MENU_LOCAL_TASK, 'callback' => 'newspaper_search'); This does not: $items[] = array('path' => 'newspaper', 'title' => t('view1'), 'type' => MENU_CALLBACK, 'callback' => 'newspaper_search', 'access' => TRUE); $items[] = array('path' => 'newspaper/search', 'title' => t('Search'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); $items[] = array('path' => 'newspaper/search/advanced', 'title' => t('Advanced search'), 'type' => MENU_LOCAL_TASK, 'callback' => 'newspaper_search'); The only difference is the path on the second local task: newspaper/advanced newspaper/search/advanced Am I asking the menu system to do something it wasn't meant to do? -- Chris Johnson irc: cxj
See: http://drupal.org/node/17022 A patch can be found there - but as Dries points out it may 'break' other modules. Since newspaper/search/advanced is a single local task (of newspaper/search) - it doesn't show up. andre Chris Johnson wrote:
This works:
$items[] = array('path' => 'newspaper', 'title' => t('view1'), 'type' => MENU_CALLBACK, 'callback' => 'newspaper_search', 'access' => TRUE); $items[] = array('path' => 'newspaper/search', 'title' => t('Search'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); $items[] = array('path' => 'newspaper/advanced', 'title' => t('Advanced search'), 'type' => MENU_LOCAL_TASK, 'callback' => 'newspaper_search');
This does not:
$items[] = array('path' => 'newspaper', 'title' => t('view1'), 'type' => MENU_CALLBACK, 'callback' => 'newspaper_search', 'access' => TRUE); $items[] = array('path' => 'newspaper/search', 'title' => t('Search'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); $items[] = array('path' => 'newspaper/search/advanced', 'title' => t('Advanced search'), 'type' => MENU_LOCAL_TASK, 'callback' => 'newspaper_search');
The only difference is the path on the second local task:
newspaper/advanced newspaper/search/advanced
Am I asking the menu system to do something it wasn't meant to do?
-- Chris Johnson irc: cxj
The menu tree is defined by the paths... The first tree is: newspaper ..newspaper/search ..newspaper/advanced The second tree is: newspaper ..newspaper/search ....newspaper/search/advanced Menu path 'directories' are not tied to a single level, but they do use the nearest parent. For example, you can have: boo ..boo/foo/bar ..boo/bar/xyzzy ..boo/moo ....boo/moo/baz ....boo/moo/bar bunny/rabbits ..bunny/rabbits/like/to/play/bingo If you were to add "boo/foo", then it becomes: boo ..boo/foo <- ....boo/foo/bar <- ..boo/bar/xyzzy ..boo/moo ....boo/moo/baz ....boo/moo/bar bunny/rabbits ..bunny/rabbits/like/to/play/bingo Steven Wittens
Thank you to Andre and Steven for clarifying for me how menu paths define the menu tree. -- Chris Johnson
participants (3)
-
Andre Molnar -
Chris Johnson -
Steven Wittens