I'm working on developing a custom module for Drupal 7. Part of the module that I'm creating is a form editing component (with an entirely different aim from something like cck, which is why I am re-inventing the wheel here). I've got one page registered to display a list of all the forms, and another registered for viewing and editing a specific form. I would like the breadcrumb on the viewing page to include a link to the listing page, however it does not appear. I am getting "Home » Administration » Jarrow ETD System", while I would like to have a "Form Editor" component on the end. The relevant hook_menu code looks like this:
$items['admin/settings/jarrow'] = array(
'title' => t('Jarrow ETD System'),
'description' => t('Configure the core settings for the Jarrow ETD system'),
'page callback' => 'drupal_get_form',
'page arguments' => array('jarrow_configure'),
'access arguments' => array('administer etd'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/jarrow/forms'] = array(
'title' => t('Form Editor'),
'description' => t('View All Forms'),
'page callback' => 'jarrow_list_forms',
'file' => 'form_editor.inc',
'access callback' => 'user_access',
'access arguments' => array('administer etd'),
'type' => MENU_LOCAL_TASK,
'weight' => 40,
);
$items['admin/settings/jarrow/forms/%/view'] = array(
'title' => t('Form View'),
'description' => t('View a Form'),
'page callback' => 'jarrow_view_form',
'page arguments' => array(4),
'file' => 'form_editor.inc',
'access callback' => 'user_access',
'access arguments' => array('administer etd'),
'type' => MENU_NORMAL_ITEM,
);
There are a significant number of other pages registered, which I have omitted. Aside from the fact that I probably shouldn't be using 'admin/settings' as my base url, I can't see anything wrong with the menu structure. Oddly enough, if I add in the following code to hook_menu, I get the right result:
$items['admin/settings/jarrow/stuff'] = array(
'title' => t('Stuff Editor'),
'description' => t('View All Forms'),
'page callback' => 'jarrow_list_forms',
'file' => 'form_editor.inc',
'access callback' => 'user_access',
'access arguments' => array('administer etd'),
'type' => MENU_LOCAL_TASK,
'weight' => 40,
);
$items['admin/settings/jarrow/stuff/%/view'] = array(
'title' => t('Stuff View'),
'description' => t('View a Form'),
'page callback' => 'jarrow_view_form',
'page arguments' => array(4),
'file' => 'form_editor.inc',
'access callback' => 'user_access',
'access arguments' => array('administer etd'),
'type' => MENU_NORMAL_ITEM,
);
This is exactly the same entry into hook_menu, down to the function it's calling, except for the url having "stuff" in it instead of "forms". However, the breadcrumb trail displays properly: "Home » Administration » Jarrow ETD System » Stuff Editor".
I took a look at the inner workings of menu.inc, and traced the execution. It appears that when Drupal assembles the menu tree for the form, it is including the child /view, whereas for "stuff" it does not. I can't for the life of me figure out why, and I am hoping someone with experience dealing with drupal's menu system can provide some explanation as to why the menu would be constructed as such.