I have a view and I am trying to rewrite the links by appending a query string.
[name_1]
is the name of the location. The various values for age[]
are the taxonomy term IDs for an exposed filter, and friends
is a profile field.
Under Rewrite results, I have checked Output this field as a link. This is my link:
location/[name_1]?age[]=27&age[]=31&age[]=35&age[]=39&age[]=43&age[]=44&friends=1
When I cut and paste the query string into the URL bar, it works fine. However, when I tell views to rewrite the string I get URLs that look like this:
location/mexico?friends=1&age[]=44
This gives me no results and a broken view.
It appears that the query strings are processed in reverse, and it only accepts the first value for age[]
-- even though when I type the same thing into the URL bar it is OK.
I tried replacing the symbols in the rewriting string like this:
location/[name_1]age%5B%5D=27&age%5B%5D=31&age%5B%5D=35&age%5B%5D=39&age%5B%5D=43&age%5B%5D=44&friends=1
Now, when I access the view, I no longer get an error, but none of the age (taxonomy term) checkboxes are checked and the URL looks like this:
http://localhost:8888/en/location/mexico?age%255b%255d=44&friends=1
So, clearly most of the age[]
values are still disappearing for some reason.
How can I rewrite the query string so that views outputs it properly?
EDIT: According to Jimajamma's comment, D6 Views suggests using %5B%5D
, as I have already tried (I'm on D7). []
didn't work for me either (this combo doesn't even work in the URL bar). Perhaps this is a bug in Views?
EDIT 2: As per the answers, this appears to be a bug in Drupal Core/Views, not a configuration error. So I attempted to avoid using Views rewrite results output as a link feature and instead just rewrite results and code the link in HTML.
The only problem with this approach is that some of the terms have spaces in their names, and I was using the convert spaces to dashes option provided by the output as a link setting to get around this. So now the links for terms that have no spaces work properly, but the links for terms with spaces are broken...
l()
, the special characters ([]?) get garbled like thislocation/mexico%3Fage%3D27%26age%3D31%26age%3D35%26age%3D39%26age%3D43%26age%3D44%26friends%3D1
. However, at least in this case nothing is cut from the link as it is in Views.