5

I am using views to create a dynamic url that contains some parameters. Unfortunately I am including the node title as a parameter and it just so happens that many of the titles contain &.

So my custom url in views looks something like this: seminar?c=[field_seminar_cycle]&n=[field_seminar_num]&t=[title]

But it seems that when creating the view the ampersands inside the [title] don't get urlencoded. I am guessing that the drupal way of building a link is to split the url based on special chars and then urlencode the others parts before joining them all together.

Is there a way to urlencode the title field before adding it to the link? Can it only be done though templates or is there any workaround though views' gui?

2 Answers 2

1

I'd wager you could refactor a bit, and substitute the id for the title and avoid the problem altogether.

However, you can see similar problems being worked on throughout the Views issue queue. Like this one, for instance.

3
  • I am sending the parameters to a webform. I did substitute the title with nid and then grabbed the title. It works for just viewing the webform. But I want to print the submission of the webform to a pdf and this is where chaos starts taking over.
    – Perisdr
    Apr 19, 2012 at 15:31
  • I fixed my problem by theming my view with a template. But your solution solved half of my problem and I also find it better to send the nid instead of the title so I am going ahead and marking your answer as correct.
    – Perisdr
    Oct 15, 2012 at 6:33
  • @Perisdr Would you mind providing your template. Am running into the same issue and it would be a life saver. Thanks!
    – NWOM
    Jan 11, 2017 at 13:25
0

Why not use the path field instead of title? Assuming you have the pathauto module running on your set up you could use path as a replacement and & would be filtered out.

For even better results used transliteration in addition to pathauto.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.