使用module:url_alter它的钩子:hook_url_outbound_alter() [英] Using module: url_alter and it's hook: hook_url_outbound_alter()
问题描述
hook_url_outbound_alter()
我正在努力寻找有关如何使用此钩子的任何文档或说明。我有一个页面: node / 1221
,当它看起来像这样: node / 1221 / profile / chn / 3
它加载该用户的配置文件。
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.
我想要漂亮的网址,以便当用户访问 departments / pch / chn / profile / 3
我想要实际加载 node / 1221 / profile / chn / 3
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.
注意:使用drupal 6,尝试别名,但没有工作。
第二次更新:
URL中的 3
是一个配置文件ID我想传递给另一个URL。我有 node / 1221 / profile / chn / 3
工作,因为它有一个面板抓住%4
参数和将其传递给面板内的视图。希望这给出更多的上下文。
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.
目前正在尝试:
/**
* 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';
}
}
仍然没有工作...访问www.domain。 com / chn什么都不做。
Still not working... visiting www.domain.com/chn does nothing.
推荐答案
尝试这样: http://drupal.org/project/subpath_alias 根据该模块的描述,它会做你想要的。
Try this: http://drupal.org/project/subpath_alias According to that module's description it does what you want it to do.
这篇关于使用module:url_alter它的钩子:hook_url_outbound_alter()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!