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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

k4v’s picture

Issue tags: +dvcs11
FileSize
1.94 KB

I added a separate form field for the query string

k4v’s picture

Status: Active » Needs review
mariogalan’s picture

Status: Needs review » Patch (to be ported)

Hi k4v, your patch works very well.

In my opinion, this should be added to views.

Thanks!

dawehner’s picture

Status: Patch (to be ported) » Needs work

PLEASE 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


+    $options['query'] = drupal_get_query_array($alter['path_query_parameters']);

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.

robertwb’s picture

FileSize
1.75 KB

This 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.

robertwb’s picture

FileSize
1.75 KB

This 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.

robertwb’s picture

Status: Needs work » Needs review
FileSize
1.97 KB

This 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.

robertwb’s picture

Example:

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]...

merlinofchaos’s picture

Oh 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.

robertwb’s picture

Will do. Thanks for the assistance!

r.b.

Honza Pobořil’s picture

#7 does not works for me. Field in settings appeared but generated link have just destination parameter.

robertwb’s picture

Hey @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.

robertwb’s picture

Category: bug » task
robertwb’s picture

FileSize
2.29 KB

At 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.

Andrei Tyuhai’s picture

Adding support for views contextual links + another field to handle anchors.

Status: Needs review » Needs work

The last submitted patch, views_output_link_as_field_get_parameters_1342124.patch, failed testing.

Andrei Tyuhai’s picture

Status: Needs work » Needs review
FileSize
4.36 KB

The last submitted patch, views_output_link_as_field_get_parameters_1342124.patch, failed testing.

robertwb’s picture

Status: Needs review » Needs work

Seeing 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.

Anonymous’s picture

#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.

robertwb’s picture

Resubmitting 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?

robertwb’s picture

Re-testing this patch.

Tomáš Fejfar’s picture

I 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:

  1. source: some/[nid]?filter%5B%5D=[tid]
  2. replaced: some/5/?filter%5B%5D=13
  3. encoded by existing code that expects unencoded url: some/5/?filter%255B%255D=13

Proposed

  1. source: some/[nid]?filter%5B%5D=[tid]
  2. replaced: some/5/?filter%5B%5D=13
  3. decoded: some/5/?filter[]=13
  4. encoded by existing code that expects unencoded url: some/5/?filter%5B%5D=13
haiyaku’s picture

Subscribing.

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.

bgustafson’s picture

Is there a reason the patch submitted by robertwb has not been added? It would be SO handy.

robertwb’s picture

Hey @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).

robertwb’s picture

Component: Miscellaneous » Code
nielsvoo’s picture

FIXED!!!

I've found out that it's actually quite simple to work around this issue, how?

  • Add a (GLOBAL) textfield to your view
  • Paste the last part of your custom URL containing the special characters (for instance &title=[title]&strp=[nid]) in the Text box
  • Save the field and sort it above your URL rewrite field
  • Use this new field as token in the Rewrite this URL field.

Let's say your text field is [nothing_1]

Hope this will help you
Niels

robertwb’s picture

Status: Needs work » Needs review

The 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.