Drupal hook_url_inbound_alter不会改变我的url [英] Drupal hook_url_inbound_alter not altering my url

查看:326
本文介绍了Drupal hook_url_inbound_alter不会改变我的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  function categorie_url_inbound_alter(& $ result,$ path ,$ path_language){
if($ path =='e'){
$ result ='user';
}
}

我打算做点更高级但我甚至不能让基本的工作。



有了这个实现,我希望如果用户去mysite.com/e,他会得到用户页。但是我得到了一个404。



在这个主题中:使用module:url_alter,它的钩子:hook_url_outbound_alter(),他们还建议你需要实现hook_boot()。但是我确实实现了这个钩子,这并没有改变行为。



更新:
我从核心安装了路径模块,并在干净的网址部分中声明了一些url别名。 (也许这会发生冲突?)



更新2:清理缓存也没有这样做。



UPDATE3:
我也尝试在htaccess文件中进行url重写。但是当url被重写时,它会破坏主题。 ( https:/ /drupal.stackexchange.com/questions/76475/drupal-does-rewrite-url-but-cant-load-css-themes/76493?noredirect=1#76493 )。所以这就是为什么我现在试图用自定义模块来做。

解决方案

我不是100%肯定的,因为我也是新来的dr​​upal。但是我想你也需要实现hook_url_outbound_alter。祝你好运。如果我找到一个更好的答案,我会发布。



干杯


I have in my module named 'categorie' a implementation of:

function categorie_url_inbound_alter(&$result, $path, $path_language) {
  if ($path == 'e') {
    $result = 'user';        
  }
}

I'm planning to do something a bit more advanced but I can't even seem to get the basic one working.

With this implementation I expect that if a user goes to mysite.com/e , he gets the user page. But I'm getting a 404.

In this topic:Using module: url_alter and it's hook: hook_url_outbound_alter() they also suggested you need to implement the hook_boot() with nothing in it. However I did implement this hook and this didn't change the behavior.

UPDATE: I have the "Path" module installed from core and I declared some url aliases in the clean url section. (Maybe this gives a conflict?)

UPDATE2: cleaning the cache didn't do the trick either.

UPDATE3: I also tries doing the url rewriting in the htaccess file. But when the url was rewritten it destroyed the theming. (https://drupal.stackexchange.com/questions/76475/drupal-does-rewrite-url-but-cant-load-css-themes/76493?noredirect=1#76493). So that's why I'm now trying to do it with the custom module.

解决方案

I'm not 100% sure, cause i'm also very new to drupal. But i think you need to implement hook_url_outbound_alter as well. Good luck. If i find a better answer i'll post it.

Cheers

这篇关于Drupal hook_url_inbound_alter不会改变我的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆