Guest User

drupal 7 menu items calling load() hook several times

a guest
Jan 9th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. foo_menu(){
  2.   $items=array();
  3.   $items['foo'] = array(
  4.     'page callback' => 'foo_list',
  5. ...
  6.     'type' => MENU_LOCAL_TASK,
  7.   );
  8.   $items['foo/list'] = array(
  9.     'type' => MENU_DEFAULT_LOCAL_TASK,
  10.   );
  11.   $items['foo/add'] = array(
  12.     'page callback' => 'drupal_get_form',
  13.     'page arguments' => array('foo_add_form'),
  14. ...
  15.     'type' => MENU_LOCAL_TASK,
  16.   );
  17.   $items['foo/%bar/edit'] = array(
  18.     'page callback' => 'drupal_get_form',
  19.     'page arguments' => array('foo_edit_form',1, 2)
  20. ...
  21.     'type' => MENU_LOCAL_TASK,
  22.   );
  23.   $items['foo/%bar/clone'] = array(
  24.     'page callback' => 'drupal_get_form',
  25.     'page arguments' => array('foo_edit_form',1, 2)
  26. ...
  27.     'type' => MENU_LOCAL_TASK,
  28.   );
  29.   $items['foo/%bar/delete'] = array(
  30.     'page callback' => 'drupal_get_form',
  31.     'page arguments' => array('foo_edit_form',1, 2)
  32. ...
  33.     'type' => MENU_LOCAL_TASK,
  34.   );
  35.  
  36.   return $items;
  37. }
  38.  
  39. foo_list($form, &$form_state) {...}
  40. foo_add_form($form, &$form_state) {...}
  41. foo_edit_form($form, &$form_state, $bar, $action){...}
  42. bar_load($barname) {
  43.   dpm($barname, 'this called several times and should return a bar-object');
  44.   ...
  45.   return $barobject;
  46. }
  47.  
  48. Problem: bar_load() is called several times even when requesting foo, foo/list or foo/add as long as menu items including %bar exist.
Advertisement
Add Comment
Please, Sign In to add comment