Drupal hook_url_inbound_alter not altering my url

寵の児 提交于 2020-01-06 17:09:07

问题


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.


回答1:


What cache did you clear ? It probably not sufficient to just clear the page cache. You can try a call to

drupal_lookup_path('wipe');

To clear the alias cache. This fixes many problems with the alias system. Other things to check are the alias database table to be sure that the alias are being set in the first place.




回答2:


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



来源:https://stackoverflow.com/questions/17176589/drupal-hook-url-inbound-alter-not-altering-my-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!