Drupal Tip - How to determine what module handles a given path
Posted by: miquel in DrupalDrupal has a sophisticated module system that allows developers to extend the CMSs functionality very easily. Each module “hooks” into Drupal by implementing hook functions. On way to use this feature is to hook different URLs to module functions. Essentially the developer in his module declares an array of url paths and what function should be called when that path is requested. This small post will show you how you can determine which module handles a specific URL. This can be quite useful for debugging and/or browsing other peoples source code to learn how to do something.
Every module in Drupal that hooks to a URL path needs to implement the hook_menu function. This hook basically tells Drupal what paths will be handled by this module. This information is read when the module is enabled and stored in a database table. In Drupal 6 this information is cached so if you modify the array returned by the hook_menu function you need to clear the cache. To determine what module is handling what path you simply need to query the menu_router table. A simple query to do this is:
path
, file
, page_callback
, type
, title
FROM
menu_router m
ORDER BY
path
This table has more information that might be useful: access_callback and access_arguments store information related to what access function is called to determine who has access to that path, page_arguments stores information related to what arguments to pass to the callback function. This is specially relevant when the page_callback function is drupal_get_form in which case Drupal will render a form and this field stores the name of the form to render.
An example usage might be:
$ drush sql cli Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1859 Server version: 5.0.77 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SELECT path, file, page_callback FROM menu_router ORDER BY path; +-----------------------------------+---------------------------------+------------------------------+ | path | file | page_callback | +-----------------------------------+---------------------------------+------------------------------+ | admin | modules/system/system.admin.inc | system_main_admin_page | | admin/build | modules/system/system.admin.inc | system_admin_menu_block_page | | admin/build/block | modules/block/block.admin.inc | block_admin_display | | admin/build/block/add | modules/block/block.admin.inc | drupal_get_form | | admin/build/block/configure | modules/block/block.admin.inc | drupal_get_form | | admin/build/block/delete | modules/block/block.admin.inc | drupal_get_form | | admin/build/block/list | modules/block/block.admin.inc | block_admin_display | | admin/build/block/list/bluemarine | modules/block/block.admin.inc | block_admin_display | | admin/build/block/list/chameleon | modules/block/block.admin.inc | block_admin_display | | admin/build/block/list/donline | modules/block/block.admin.inc | block_admin_display | ..... mysql>
Entries (RSS)