In some cases it would be nice if contrib modules could extend router items with additional information.

Some of this already works:
- You can use hook_menu() and hook_menu_alter(), to put arbitrary stuff into router items.
- You can use hook_schema_alter(), to add additional columns to the menu_router table.

Problem:
The columns are hardcoded in _menu_router_build() (D6) and _menu_router_save() (D7), so none of the stuff added via hook_menu() or hook_menu_alter() will ever get into the database.

Possible solutions:
a) Allow to add new columns via contrib, and make sure that data added via hook_menu for these additional columns is not discarded.
b) Add a general-purpose "route_options" column, storing a serialized array.

Use cases I can think of atm:
1) D7 has two additional columns in the menu_router table, named 'theme_callback' and 'theme_arguments'. If this functionality was non-existant, there would be no chance for contrib to add it.
2) A new 'menu_parent' or 'menu_parent_callback' could be used to give a hint about a router item's position in a menu tree, to override the automatic behavior of just chopping off the last path fragment.
3) For the Crumbs module I had the idea to allow a 'crumbs_parent' and 'crumbs_parent_callback' callback in the router item, that would be used to determine the parent breadcrumb item.
4) For the Crumbdown module, or other modules with a similar purpose, there could be a callback in the router item to determine possible values for the wildcard arguments. These would be used to build link items to be displayed in a dropdown menu.
5) A similar technique could be used for admin_menu, to automatically generate submenu items for paths with wildcards. For instance, 'admin/content/taxonomy/%taxonomy_vocabulary' could automatically get a submenu with one item for each vocabulary.

It can be discussed whether it is a good idea to put all of the above into menu_router. Maybe it is not.
Still, worth to think about it. And maybe there are other use cases I have not thought about yet.

Comments

pwolanin’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

removing menu_router in 8x