Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG Cleaner handling of querystring arguments when selecting locale

  • Loading branch information...
commit 22c5098f8e27e42d7124e22b2172df1f88c7222e 1 parent 709e2fd
@tractorcow tractorcow authored chillu committed
View
2  code/controller/TranslatableCMSMainExtension.php
@@ -44,7 +44,7 @@ function init() {
$req->param('Action'),
$req->param('ID'),
$req->param('OtherID'),
- '?' . http_build_query($getVars)
+ ($query = http_build_query($getVars)) ? "?$query" : null
));
}
}
View
17 javascript/CMSMain.Translatable.js
@@ -36,10 +36,19 @@
this._super();
},
onchange: function(e) {
- var url = $.path.addSearchParams(
- document.location.href.replace(/locale=[^&]*/, ''),
- {locale: $(e.target).val()}
- );
+ // Get new locale code
+ locale = {locale: $(e.target).val()};
+
+ // Check existing url
+ search = /locale=[^&]*/;
+ url = document.location.href;
+ if(url.match(search)) {
+ // Replace locale code
+ url = url.replace(search, $.param(locale));
+ } else {
+ // Add locale code
+ url = $.path.addSearchParams(url, locale);
+ }
$('.cms-container').loadPanel(url);
return false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.