On this page
function hook_url_outbound_alter
hook_url_outbound_alter(&$path, &$options, $original_path)
Alters outbound URLs.
Parameters
$path: The outbound path to alter, not adjusted for path aliases yet. It won't be adjusted for path aliases until all modules are finished altering it, thus being consistent with hook_url_inbound_alter(), which adjusts for all path aliases before allowing modules to alter it. This may have been altered by other modules before this one.
$options: A set of URL options for the URL so elements such as a fragment or a query string can be added to the URL.
$original_path: The original path, before being altered by any modules.
See also
url()
Related topics
File
- modules/system/system.api.php, line 4337
- Hooks provided by Drupal core and the System module.
Code
function hook_url_outbound_alter(&$path, &$options, $original_path) {
// Use an external RSS feed rather than the Drupal one.
if ($path == 'rss.xml') {
$path = 'http://example.com/rss.xml';
$options['external'] = TRUE;
}
// Instead of pointing to user/[uid]/edit, point to user/me/edit.
if (preg_match('|^user/([0-9]*)/edit(/.*)?|', $path, $matches)) {
global $user;
if ($user->uid == $matches[1]) {
$path = 'user/me/edit' . $matches[2];
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_url_outbound_alter/7.x