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.
Reproduce:
- Create a term with an ampersand (&).
- Create a panel (for example) such that this term name is sent to a view as an argument.
- Create a view that receives the term name as a Contextual Filter, provides a Validation criteria of type Taxonomy term, and uses Filter type Term name converted to term id.
The terms with an ampersand will not be properly converted, thus resulting in an empty view.
Comment | File | Size | Author |
---|---|---|---|
#18 | views-ampersand_in_contextual_filter-1768738-12.patch | 941 bytes | lmeurs |
#13 | views-ampersand_in_contextual_filter-1768738-12.patch | 941 bytes | lmeurs |
#6 | views-term_arg_decode_entities-1768738-6.patch | 726 bytes | jeffschuler |
#2 | term-decode.patch | 545 bytes | eckroth |
term-decode.patch | 515 bytes | eckroth | |
Comments
Comment #2
eckroth CreditAttribution: eckroth commentedComment #3
eckroth CreditAttribution: eckroth commentedComment #5
eckroth CreditAttribution: eckroth commentedI'll read up on how to format a patch later... it's a one-liner so it should be easily understood even without automated testing.
Comment #6
jeffschulerLooks like your patch is missing another newline at the end.
I could apply it using the patch utility, but not with git apply.
Rerolled
Comment #7
freak1321 CreditAttribution: freak1321 commentedComment #8
omerida CreditAttribution: omerida commentedthis patch fixed this issue for me
Comment #9
Geijutsuka CreditAttribution: Geijutsuka commentedIs this issue related to #672606: Hyphens and forward slashes (-/) break Views contextual filters? It would be great if this patch killed two issues.
Edit: sorry, didn't mean to reference the same issue...
Comment #10
segx CreditAttribution: segx commentedJust curious, will this patch be in the next Views release?
Comment #11
meeli CreditAttribution: meeli commentedIf you select the option to convert spaces in term names to hyphens this patch is no longer effective. Investigating this now, I'll post a patch if I can figure it out.
Comment #12
jyraya CreditAttribution: jyraya commentedHello meeli,
Selecting option "convert spaces in term names to hyphens" did not work for me when I pass the argument through a views pane context and the passed name come from a term reference field value. The ampersand contained in the term name is still "&".
The patch supplied by jeffschuler worked for me (thanks for it!).
I think that the decode_entities should also applied when the the option "convert spaces in term names to hyphens" because of other special characters that could be to convert like "é", "ç", "ô".
Do you see a case where that could not work by applying the decode_entities in this case?
Comment #13
lmeurs CreditAttribution: lmeurs commentedThanks for the patch!
@jyraya, @meeli: I cannot find the option Convert spaces in term names to hyphens, is this in Panels or Views?
I did find the Transform dashes in URL to spaces in term name filter values option in the Views' contextual filter dialog window. The patch from #6 does not take this option into account, it only decodes entities if the
transform
option has not been set.Attached patch decodes entities in both cases, please review and set RTBC if all is ok!
Comment #14
afoster CreditAttribution: afoster commented#13 worked for me. thanks!
Comment #15
RumpledElf CreditAttribution: RumpledElf commentedJust hit this myself - I was using a term contextual filter both on a page view and a block on the same page view. This issue only affected the block view and ONLY because it had an exposed filter and did a keyword search via ajax. The search worked fine in preview but not on the actual view page, and the term correctly converted with an ampersand in it to get the base category contextual filter on the block, just not with the ajax exposed filter keyword search.
Patch in #13 also worked for me, count me in as another happy reviewed-and-tested-it community member.
Comment #16
froboyI'm having trouble with getting this to work. Could someone who's successfully tested post the term names they've tested with? It seems to me that this still doesn't fix the issue. It looks like it's decoding entities in the argument, but not in the td.name, which is what we need, right? I have terms like "Arts & Humanities" which don't match with the
Playing around with the query, I came up with this:
but that seems hacky and probably not valid behavior for every case, maybe? What I (we?) really need is to totally clean the string like in pathauto_cleanstring or ctools_cleanstring and at that point using merlinofchaos's advice is probably simpler (and what I'll most likely do). Can someone give me a sanity check here? If it looks valid, I can set it up for both cases and submit a new patch.
Comment #17
colanWe've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.
If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.
We apologize for the trouble, and appreciate your patience.
Comment #18
lmeurs CreditAttribution: lmeurs commentedRe-uploading the patch from #13.
Comment #19
lmeurs CreditAttribution: lmeurs commentedSet status back to RTBC according to the request in #17.
Comment #20
victoriachan CreditAttribution: victoriachan at Torchbox for University of Oxford commentedThanks for the patch. Just to feedback on this, I have tried the patch on #18, but though it fixes the problem on the 2nd page, it broke again on the 3rd page. We're using Views 7.x-3.11.
Comment #21
Jim.M CreditAttribution: Jim.M as a volunteer commentedHey,
I've got the same problem described in #3.
I have a page /content/Internet-&-Media where the "Internet & Media" is the taxonomy term name.
A message appears "Page not found" (generated by Views module). Also, I've added Override title option in the contextual filter and the title shows only the part of the title - "Internet".
The /content/Internet-%26-Media path works fine. I'm using Views 7.x-3.14.
If you need additional info - just ping me.
Comment #22
DamienMcKennaSounds like this needs more work, maybe a test would help too?
Comment #23
Summit CreditAttribution: Summit as a volunteer commentedHi, after 2 years not correct working still..anyone have a solution please?
Comment #24
safetypinI had assumed (obviously incorrectly) that views would treat this like pathauto does, and sluggify a term like "Anthropology & Sociology" into "anthropology-sociology"
Comment #25
Summit CreditAttribution: Summit as a volunteer commentedHi Safetypin, I had the same assumption...but no solution yet.
Anyone have a solution please?
greetings, Martijn