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.
The "Output this field as a link" option escapes some characters that I think shouldn't be escaped.
This is the string I'm using:
node/[nid]&width=500&height=500&iframe=true&scrolling=false
And these are the urls that views is constructing:
/?q=node/247%26width%3D500%26height%3D500%26iframe%3Dtrue%26scrolling%3Dfalse
If I try to escape the "&" character using %26, it encodes the "%" making things even worse.
Comment | File | Size | Author |
---|---|---|---|
#22 | linkparams_2.patch | 2.29 KB | robertwb |
| |||
#14 | linkparams.patch | 2.29 KB | robertwb |
#5 | 1342124-02.patch | 1.75 KB | robertwb |
#1 | 1342124.patch | 1.94 KB | k4v |
Comments
Comment #1
k4v CreditAttribution: k4v commentedI added a separate form field for the query string
Comment #2
k4v CreditAttribution: k4v commentedComment #3
mariogalan CreditAttribution: mariogalan commentedHi k4v, your patch works very well.
In my opinion, this should be added to views.
Thanks!
Comment #4
dawehnerPLEASE if you don't know how to use issue status etc. please don't change them.
For example "patch (to be ported)" means that it's already added to the code, but should be ported to another major version.
So this patch basically got lost because of the changing
It would be kind of cool if this would allow to use tokens as well, similar to all other settings.
I don't think you intended to remove that.
Thanks for your work btw.
Comment #5
robertwb CreditAttribution: robertwb commentedThis patch fails partially in 7.x-3.5 because of some slight changes to the file "views_handler_field.inc". The attached is an update to the patch.
I would say, however, that the above patch only partially fixes things since the resulting URL parameters are unable to benefit from things such as replacement pattern tokens (which is what I require). It would be nice if the tokens could be subbed in. I am working on that currently.
r.b.
Comment #6
robertwb CreditAttribution: robertwb commentedThis patch fails partially in 7.x-3.5 because of some slight changes to the file "views_handler_field.inc". The attached is an update to the patch.
I would say, however, that the above patch only partially fixes things since the resulting URL parameters are unable to benefit from things such as replacement pattern tokens (which is what I require). It would be nice if the tokens could be subbed in. I am working on that currently.
r.b.
Comment #7
robertwb CreditAttribution: robertwb commentedThis patch adds the token replacement code mentioned in post #5 (& #6). It should now allow the use of replacement tokens in the field "Rewrite Results -> Output this field as a link -> Query Parameters".
I am very new to using diff and patch and am pretty sure that I am using it wrong since you have to cd into the "handlers" sub-directory of the views module to apply the patch properly - if anyone cared to comment on the proper way to do this it would be great.
Also, would be nice to know if this is a beneficial feature to all but our few cases. Status changed to "needs review", hope that was OK.
r.b.
Comment #8
robertwb CreditAttribution: robertwb commentedExample:
Link Path: node/[nid_1]/edit
Query Parameters: destination=agr/[nid]/water_source
Final URL: http://deq3.bse.vt.edu/d.test2/?q=node/169693/edit&destination=agr/16969...
Previous patch would have yielded Final URL:
http://deq3.bse.vt.edu/d.test2/?q=node/169693/edit&destination=agr/[nid]...
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedOh yes, you're totally using the wrong diff format, too.
What you want to do is make sure you apply your changes to a git checkout (see the "revision control" tab of the project for how to get one).
Once you've done that, you can (as long as you're not adding new files) simply do: git diff > filename.patch from the root directory of the module, and attach that file.
Comment #10
robertwb CreditAttribution: robertwb commentedWill do. Thanks for the assistance!
r.b.
Comment #11
Honza Pobořil CreditAttribution: Honza Pobořil commented#7 does not works for me. Field in settings appeared but generated link have just destination parameter.
Comment #12
robertwb CreditAttribution: robertwb commentedHey @Bobik - that patch was a pretty poor attempt on my part - that is, the code works, but the method that I used to create the patch was non-conforming. You have to apply it via the command line. MerlinofChaos told me how to go about learning to create a proper patch but I have yet to take that step. I am hoping to in the next couple of weeks and perhaps this will help me along.
r.b.
Comment #13
robertwb CreditAttribution: robertwb commentedComment #14
robertwb CreditAttribution: robertwb commentedAt long last - I finally think that I have created a proper patch against the current dev branch. See attached.
Thanks to @merlinofchaos for the guidance.
r.b.
Comment #15
Andrei Tyuhai CreditAttribution: Andrei Tyuhai commentedAdding support for views contextual links + another field to handle anchors.
Comment #17
Andrei Tyuhai CreditAttribution: Andrei Tyuhai commentedComment #19
robertwb CreditAttribution: robertwb commentedSeeing that this patch worked on the other thread, but not here, and looking at the Details of the failed patch:
"Detect a non-applicable patch
Ensure the patch applies to the tip of the chosen code-base."
It seems like the patch you have is for a different version of the code. You need to use the current branch,
r.b.
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commented#2072617: Remove Unused local variable $base from /core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php, part of #2072597: Remove Unused local variables from tests in the Views module turns out to be a commented out test for this issue so making a note here for merging re-enabling of the test once issue resolved.
Comment #21
robertwb CreditAttribution: robertwb commentedResubmitting the patch from #14 since it tests OK and there is a problem with the patch in #15 and #17. It would be nice to get this into the main, so perhaps the 15/17 patches can go into a separate thread?
Comment #22
robertwb CreditAttribution: robertwb commentedRe-testing this patch.
Comment #23
Tomáš Fejfar CreditAttribution: Tomáš Fejfar commentedI am a newbie in Drupal, so bear with me. I don't know if I understand this correctly.
The percent signs are encoded for a reason. Wouldn't it be best to url_decode the URL after the replacements are replaced and before it's encoded for output?
Currently:
Proposed
Comment #24
haiyaku CreditAttribution: haiyaku commentedSubscribing.
Views also escapes URL's with colons, breaking certain links:
www.example.com/function?web=http://www.example.com/ results in this link: http://www.example.com/function?web=http://www.example.com/&web=http%3A/...
Work around is to rewrite the field as a link to refer to itself.
Comment #25
bgustafson CreditAttribution: bgustafson commentedIs there a reason the patch submitted by robertwb has not been added? It would be SO handy.
Comment #26
robertwb CreditAttribution: robertwb commentedHey @bwaldmann - I think it is really hard to get things committed into Views, especially for D7 - but I think that if you can test this out and help build support for it to move to "RTBC" that might be a step in the right direction. Another thing that moves these forward, as I understand it, is if it gets moved into D8, so that this D7 version becomes a "backport". I am working on finding the time for that (if it has not already been done by someone else).
Comment #27
robertwb CreditAttribution: robertwb commentedComment #28
nielsvoo CreditAttribution: nielsvoo commentedFIXED!!!
I've found out that it's actually quite simple to work around this issue, how?
Let's say your text field is [nothing_1]
Hope this will help you
Niels
Comment #29
robertwb CreditAttribution: robertwb commentedThe patch actually works to provide a fix (changing to needs review to trigger test bot), and my sense had been that there are some things that get escaped improperly with more complex URLs, which is why the custom text approach doesn't work for all cases. As a personal note, I prefer having the URL and it's params all defined in a single place if I can.