Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.330 diff -u -p -r1.330 menu.inc --- includes/menu.inc 20 Jul 2009 01:28:16 -0000 1.330 +++ includes/menu.inc 29 Jul 2009 17:33:40 -0000 @@ -406,6 +406,11 @@ function menu_execute_active_handler($pa return MENU_ACCESS_DENIED; } } + $current_path = isset($path) ? $_GET['q'] : NULL; + $page_not_found = module_invoke_all('page_not_found', $current_path); + if (isset($page_not_found) && is_array($page_not_found) && isset($page_not_found['status_code'])) { + return $page_not_found['status_code']; + } return MENU_NOT_FOUND; } @@ -1269,7 +1274,7 @@ function theme_menu_tree($tree) { * The menu item's LI element is given one of the following classes: * - expanded: The menu item is showing its submenu. * - collapsed: The menu item has a submenu which is not shown. - * - leaf: The menu item has no submenu. + * - leaf: The menu item has no submenu. * * @ingroup themeable * Index: modules/menu/menu.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.api.php,v retrieving revision 1.9 diff -u -p -r1.9 menu.api.php --- modules/menu/menu.api.php 11 Jul 2009 13:56:21 -0000 1.9 +++ modules/menu/menu.api.php 29 Jul 2009 17:33:41 -0000 @@ -148,5 +148,36 @@ function hook_translated_menu_link_alter } /** + * Execute this hook when the current path would result in a 'page not found' + * response. + * + * This hook may be used, for example, to load balance files located on + * different servers, or to check a subdomain for a path to redirect to. + * + * The menu return status can be changed by returning an array with the key + * 'status_code' set to the desired constant. + * + * @see menu.inc + * + * @param $path + * The system path which was not found. + * + * @return + * An optional array containing a 'status_code' key corresponding to a menu + * return constant from menu.inc. + */ +function hook_page_not_found($path) { + // Example - determine if the URL is available at a different site, and + // redirect if that URL is available. + $remote_url = variable_get('offsite_redirect_site', FALSE); + if ($remote_url) { + $result = drupal_http_request($remote_url . $path); + if (floor($result->code / 100) * 100 == 200 || floor($result->code / 100) * 100 == 300) { + drupal_goto($remote_url . $path); + } + } +} + +/** * @} End of "addtogroup hooks". */