function hook_url_outbound_alter in URL alter 6
Hook implementation of custom_url_rewrite_outbound().
Alter links generated by Drupal.
This function can change the value of $path and $options since they are passed by reference.
This function is called from url(). Please note that this function is called very frequently so performance is critical.
To change a link from an internal link to an external link, you would set $options['base_url'] to the base URL of the link and also set $options['absolute'] to TRUE. This will only work if clean URLs are enabled.
Parameters
$path: The alias of the $original_path as defined in the database. If there is no such match in the database it will be the same as $original_path.
$options: An associative array of additional options that were passed to url().
$original_path: The unaliased Drupal path that is being linked.
1 function implements hook_url_outbound_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- url_alter_url_outbound_alter in ./
url_alter.module - Implementation of hook_url_outbound_alter().
1 invocation of hook_url_outbound_alter()
File
- ./
url_alter.api.php, line 92 - Documentation for url_alter API.
Code
function hook_url_outbound_alter(&$path, &$options, $original_path) {
global $user;
// Change all links for 'node/x' to 'article/x'.
if (preg_match('|^node(/.*)|', $path, $matches)) {
$path = 'article' . $matches[1];
}
// Change all links to the user's profile edit page to a path 'e'.
if ($path == 'user/' . $user->uid . '/edit') {
$path = 'e';
}
}