Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using the jump menu with a grouping field, the contents of this field is escaped using the url() function, transforming any non-ascii characters into url-encoded form. This can be fixed by commenting the line 91 in views_plugin_style_jump_menu.inc :
$grouping = url($grouping);
Is this line even necessary, it's just a label and not any form of link.
Comment | File | Size | Author |
---|---|---|---|
#26 | topic_subtopic_jump.jpg | 68.35 KB | lhugg |
#22 | 746846-fix-slightly-broken-jump-menu2.patch | 3.06 KB | merlinofchaos |
#21 | 746846-fix-slightly-broken-jump-menu.patch | 2.44 KB | merlinofchaos |
#16 | 746846-proposed_fix2.patch | 894 bytes | lavamind |
#6 | 746846-screenshot.png | 10.74 KB | lavamind |
Comments
Comment #1
dawehnerCan you provide a patch?
I'm not sure whether this really fixes the Problem, because the goal of the jumping menu has to be a url.
Comment #2
lavamind CreditAttribution: lavamind commentedHere's the patch :
The jump menu options should indeed have a URL as value, but this function doesn't seem related to that specific line. The
$grouping
value goes into the "label" parameter of the "optgroup" tag, which is defined as a text field according to the HTML spec : http://www.w3.org/TR/html401/interact/forms.html#adef-label-OPTGROUPComment #3
dawehnerA patch file would be better.
Comment #4
dawehner.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedurl() ensured that it was fully qualified, which is necessary if your base_url is something like http://www.example.com/foo or if you are not using clean URLs. It is necessary.
Comment #6
lavamind CreditAttribution: lavamind commentedI've attached a screenshot of the problem, to make the things clearer. As you can see it's the grouping label, and only the grouping label, that appears URL-encoded. The corrupted value displayed are role titles, and they appear correctly everywhere else on the site. Looking at the markup, the select option values (URL paths, usually) do not appear to be processed by url() at all.
I've looked at the problem more closely and it appears that it's simply the wrong value that's passed through url(). It should be $path instead of $grouping, the latter being nothing more than a text label. I've checked in 6.x-2.x-dev and the problem is the same there.
Here's a patch file to apply against 6.x-2.x-dev.
I verified that 1) it fixes the group encoding problem and 2) it applies the url() filter to the proper value.
If this patch is accepted it might be useful to note that with this change, in some cases it might be necessary to review the settings on views fields exposed as the jump menu URL path : in my case I had added a forward-slash at the beginning of the field value rewrite (ie. /user/[uid] instead of user/[uid]), which caused confusion in url().
Comment #7
khosman CreditAttribution: khosman commentedThanks, lavamind -
I applied your changes and solved the issue with the group listing - but a problem remains with the listings appearing under the groups. Specifically, if they have a single quote/apostrophe, it appears encoded. Do you have a suggestion as to how to fix this?
Comment #8
ñull CreditAttribution: ñull commentedYou applied it but I still see the issue in my version. Could you redo it that it gets included for version 6.x-2.11 ?
Comment #9
ñull CreditAttribution: ñull commentedI worked around it by using custom PHP field for the fields I wanted included there:
However in your code you could probably use something like html_entity_decode
Comment #10
khosman CreditAttribution: khosman commentedWow - well, that workaround works great...but... how and why? I put the variable I wanted to see used as the choices in the dropdown into your code and it worked. But why does appending/concatenating another field (users_name) cause it to read the apostrophes correctly?
Comment #11
HunterElliott CreditAttribution: HunterElliott commentedHmm... well, for me, it's not a path/grouping issue (or so I think), because I have no grouping going on in my dropdown/jump menu and the "jumps" do work. However, all of my text that has ampersands and/or apostrophes is being parsed out into entities. For instance, George's appears as
Georges'
or Restaurant & Wine bar appears asRestaurant & Wine Bar
I tried the patch above and my problem still exists. Suggestions? I saw someone having a similar issue but it was marked as a duplicate of this thread.
Comment #12
khosman CreditAttribution: khosman commentedHunterElliot, scroll up to comment #9 from "com2." His first fix worked for me (per my comment) - but I ended up going with his second suggestion, namely to use "html_entity_decode." Follow his link above (again, many thanks, com2) for instructions - its simple and works beautifully.
Here, specifically, is the code I employed:
echo html_entity_decode($data->node_title, ENT_QUOTES);
Toss in the opening and closing php tags and it works like a charm.
Comment #13
HunterElliott CreditAttribution: HunterElliott commentedwell, I went to try and theme my jump menu view, and it's coming back with the error:
"Style output: views-view-jump-menu.tpl.php (File not found, in folder sites/all/modules/views/theme/)"
Could this be part of the issue? I'm looking back through my previous versions of this module and am not finding this file in any of them so far.
Is this file needed?
Comment #14
CubicX CreditAttribution: CubicX commentedIndeed, this file seems to be missing in all theme's.
Comment #15
HunterElliott CreditAttribution: HunterElliott commentedThanks, khosman (sorry for the delay in a follow-up) - I basically did this.
The actual jump menu I created worked fine, just the text output was "funky." I created a .tpl.php file specifically for my Title field (of course, you could do it for any field in the View, I just used the template off of the themeinfo: views-view-field.tpl.php).
All I did in it was put the following:
and that cleared everything up.
Comment #16
lavamind CreditAttribution: lavamind commented@khosman, HunterElliot: Your issues with html entities could be fixed by replacing
$grouping = url($grouping);
with$grouping = html_entity_decode($grouping);
, instead of deleting the line completely as my previous proposed patch does, see #6.However we should be careful about quotes because that string is placed into a HTML parameter that's surrounded by double-quotes. If
html_entity_decode
produces such quotes in 'normal' form, the label will be cut-off and the resulting HTML will be invalid. A safer solution would be to add the ENT_NOQUOTES parameter, though single quotes still won't be converted (that could be done seperately).EDIT: I re-read the thread and it's not clear if your issues are related to the grouping label and/or the option list items only. If your issue is with option list items only (which I think it is), then this new patch doesn't apply, please disregard it. Furthermore, issues with option list items in the jump menu should probably be treated in a seperate issue thread. This issue was opened only to deal with grouping labels and that's what my first patch (#6) deals with.
Comment #17
lavamind CreditAttribution: lavamind commentedDespite unrelated encoding problems raised in this thread, I think the patch in #6 properly deals with the discrete problem I raised in my initial message.
Comment #18
lliss CreditAttribution: lliss commentedPatch discussed in #6 is pretty clean and fixed the problem. Nice work. Thanks.
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedApplied the patch in #6 to all branches.
Comment #20
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commented#6 broke a jump menu view of mine.
I have set it up without a grouping field but using Nid as a path field. The nid field is set to be excluded and rewritten using node/[nid]/edit.
After applying the patch the redirect would happen to http://node/n/edit, ie the domain was missing.
Comment #21
merlinofchaos CreditAttribution: merlinofchaos commentedI believe this fixes killes' problem.
Comment #22
merlinofchaos CreditAttribution: merlinofchaos commentedHm. Another try, it seems killes is doing query string tricks too, and those used to work but no longer.
Comment #23
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commentedYep, this works!
Comment #24
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to all branches.
Comment #26
lhugg CreditAttribution: lhugg commentedIt doesn't look like this patch made it to 6.12. I'm having the same issues. Shouldn't these changes have remained in the branch?
Comment #27
merlinofchaos CreditAttribution: merlinofchaos commentedPlease read 2.12's release notes.
Comment #28
lhugg CreditAttribution: lhugg commentedSo what does "committed to all branches" mean? Only code obtained through CVS? Should we apply the patch to the downloaded or Acquia versions?
Comment #29
dawehnerCommited to all branches means it's commited to the 2.x-dev version.
But as you can read on the release announcement 2.12 is exactly 2.11 with one patch: the security patch.
Comment #30
merlinofchaos CreditAttribution: merlinofchaos commentedBy the way, 'Please read the release notes' does not mean 'ignore the release notes and ask anyway,' it means read the release notes. If you had read the release notes, like I said, you would not have needed to ask the followup question.
Comment #31
lhugg CreditAttribution: lhugg commentedThanks dereine for answering my question, which is what is meant in drupalese by "Committed to all branches." I did read the notes and understood that this patch was not in release 2.12, but still wanted to know for future reference what a developer meant specifically when they said that a patch had been applied to all branches. Apparently that means only the dev versions.
Thank you for taking the time to help me out. The more learn, the stronger we become as a community.