hook_url_outbound_alter()
I am struggling to find any documentation or explanation for how to use this hook. I have a page: node/1221
and when it look like so: node/1221/profile/chn/3
It loads a profile for that user.
I want pretty URL's so that when the user visits departments/pch/chn/profile/3
I want it to actually load node/1221/profile/chn/3
I am pretty sure the hook should help me with this but not sure how it works.
Note: Using drupal 6, tried aliases but they didn't work.
2nd update:
The 3
in the URL is a profile ID that I want to pass on to another URL. I have node/1221/profile/chn/3
working because it has a panel that grabs the %4
argument and passes it to a view inside the panel. Hope this gives more context.
Currently trying:
/**
* Implementation of hook_boot()
*/
function pathargs_boot() {
// remain empty, only needed to let Drupal bootstrap system know to load this module earlier.
}
/**
* Will define custom_url_rewrite_inbound(). If url_alter is enabled
* Pathargs inbound alter will be called by its implementation of
* custom_url_rewrite_inbound() instead.
*/
if (!function_exists('custom_url_rewrite_inbound')) {
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
return pathargs_url_inbound_alter($result, $path, $path_language);
}
}
/**
* Implementation of hook_url_inbound_alter()
*/
function pathargs_url_inbound_alter(&$result, $path, $path_language) {
watchdog('Path Arguments', "$path + $original_path");
if($result == 'chn') {
$result = 'node/1222/chn/profile/3';
}
}
Still not working... visiting www.domain.com/chn does nothing.
3
in the URL is a profile ID that I want to pass on to another URL. I havenode/1221/profile/chn/3
working because it has a panel that grabs the%4
argument and passes it to a view inside the panel. Hope this gives more context. - JeroenEijkhof