Hi,
Just in case anyone finds this useful, I have slightly modified the snippet that presents the flags with language choices. In my case I have a multi-lingual MaxiGallery, as in
http://modxcms.com/forums/index.php/topic,24577.0.html , which in "normal" view uses GET variables to choose which picture to display.
Thus I have added to the snippet the following code:
// Recreate GET query, but remove q term
$get = "";
if (sizeof($_GET) > 1) {
$getArray = $_GET;
unset($getArray['q']);
$get = "?".http_build_query($getArray);
}
And replaced
$modx->makeUrl($targetid)
by
$modx->makeUrl($targetid).$get
This adds the original GET query onto the URL for the translation. Thus people can move from a picture in one language to a picture in another if they wish.
Note: the "remove q term" is because I use friendly URLs: I think the q term is added "internally" by the .htaccess file and contains the path to the document requested. This seems to be part of the $_GET variable, but it is not required when constructing links. I’m not sure what would happen if friendly URLs are off.
Also: I’m by no means a PHP expert, so what I’ve written could be done in a better way, or there could be some cases where this does something dodgy!
Michal