3

I have an administration system setup in a custom module that controls groups of items and specific items. The item groups can be added, edited, or removed and each item groups associated items can also be added, edited, or removed.

The current path structure is like this:

$items['admin/config/esc_shared/esc_shared_lists'] = array(
    'title' => 'Shared Lists',
    'description' => 'View current set of options.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_view_groups_form'),
    'access arguments' => array('manage list options'),
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/settings'] = array(
    'title' => 'Settings',
    'description' => 'Manage shared list options.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_settings'),
    'access arguments' => array('administer shared lists'),
    'file' => 'includes/esc_shared_lists.admin.inc',
    'weight' => 0,
);
$items['admin/config/esc_shared/esc_shared_lists/manage'] = array(
    'title' => 'Manage',
    'description' => 'Manage list options.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_view_groups_form'),
    'access arguments' => array('manage list options'),
    'file' => 'includes/esc_shared_lists.manage.inc',
    'weight' => 1,
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/add'] = array(
    'title' => 'Add group',
    'description' => 'Add a list option group.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_group_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'includes/esc_shared_lists.manage.inc',
    'weight' => 2,
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/edit'] = array(
    'title' => 'Edit group',
    'description' => 'Edit a list option group.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_group_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/remove'] = array(
    'title' => 'Remove group',
    'description' => 'Remove a list option group.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_group_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/options'] = array(
    'title' => 'List options',
    'description' => 'View list options for a specific list.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_view_options_form'),
    'access arguments' => array('manage list options'),
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/options/add'] = array(
    'title' => 'Add option',
    'description' => 'Add list options to a specific list.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_options_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/options/%/edit'] = array(
    'title' => 'Edit option',
    'description' => 'Edit list option for a specific list.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_options_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/esc_shared_lists.manage.inc',
);
$items['admin/config/esc_shared/esc_shared_lists/manage/group/%/options/%/remove'] = array(
    'title' => 'Remove option',
    'description' => 'Remove list option from a specific list.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('esc_shared_lists_admin_manage_options_form'),
    'access arguments' => array('manage list options'),
    'type' => MENU_CALLBACK,
    'file' => 'includes/esc_shared_lists.manage.inc',
);

There are other menu tree items but for brevity's sake I'm only pasting the relevant branches.

The issue I'm having is that everything works as expected up to and including getting a list of items from a group. From there if you try to edit or remove an item it just ignores the second /% and /edit.

I've done this before but slightly different. The difference being that it was a structure like:

admin/config/modulename/grouptype/%/itemtype/%/edit

If I change my paths to remove /manage from them it works as expected.

admin/config/esc_shared/esc_shared_lists/manage/group/%/options/%/edit // does not work
admin/config/esc_shared/esc_shared_lists/group/%/options/%/edit // works

What I want to know is why that would make any difference. I should be able to put any number of arguments in a path mixed with wildcards and it should behave the way one would expect.

It would almost make sense if it was defaulting all paths containing admin/config/esc_shared/esc_shared_lists/manage to that page. But instead it only screws up after the first wildcard.

Is this some kind of bug?

4

It's not a bug, but it's probably not obvious why that doesn't work - the number of menu parts is limited to 9, by the MENU_MAX_PARTS constant:

The maximum number of path elements for a menu callback

Your first path has 10 parts so won't be parsed properly by the various functions in menu.inc (menu_get_item() notably).

|improve this answer|||||
  • Ah, I had no idea that even existed. Good to know. Thanks! – Jason Gray Aug 29 '13 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.