Hello,
I have defined a custom_url_rewrite() function in my settings.php.
When going from source -> alias, it prefixes the language ('lang-en/' or 'lang-nl/') to the url and ...
when going from alias -> source, it strips the language from the url.
It works fine, except for one thing ... Some forms (including the login form :-/ ) redirect to a URL like
lang-nl/lang-nl/user/login?time=1155399481
The action attribute on the <form> element already contains the language prefix
and I guess after the form input is received, drupal_goto() is called on the destination url
again and custom_url_rewrite() then adds the prefix again ...
I think this is a bug, though I'm not entirely sure either whether I'm not doing something stupid myself ;-)
I tried to locate the exact cause of the problem, but it's taking me too much time :-/
So I'm posting the fragment from my settings.php below.
Hope someone can tell me what's going wrong.
Best regards,
Eric
if(preg_match('/^lang-en(\/|$)/', $_GET['q'])) {
$GLOBALS['wkvlanguage'] = 'en';
} else {
$GLOBALS['wkvlanguage'] = 'nl';
}
function custom_url_rewrite($type, $path, $original) {
// $type is either 'alias' or 'source', depending on the
// desired resulting path type of the operation (to be
// in line with drupal_lookup_path() operation),
// $path is possibly already processed by Drupal,
// $original is the originally passed path
global $wkvlanguage;
$retval = $path;
if ($path == $original) {
// path is not yet aliased (this is the only case
// conf_url_alias() was invoked in earlier versions)
if ($type == 'source') {
// Convert alias to real/source url.
$retval = preg_replace('/^lang-(en|nl)\//', '', $retval);
$retval = preg_replace('/^lang-(en|nl)$/', 'node', $retval);
} else {
// Convert real/source url to alias
$retval = "lang-$wkvlanguage/$path";
}
}
return $retval;
}
Comments
I think I found the bug in common.inc
I modified drupal_get_destination() to the following. It seems to work very well: