Problem generating a link within a View

Joined: 09/09/2008

I'm stumped and I need some help.

Here's the environment:

  • Drupal 6.11
  • Views 6.x-2.5
  • Prepopulate 6.x-2.x-dev

I've got a view that produces a list of courses (courses is a CCK node type). I've got a Register webform for registering. The form has a date field (actually a simple textfield designated to hold a date). I want to generate a link from the view to the webform that prepopulates the date field.

The code in the Link Path field for the date field in the view is:
register/insurance?edit[submitted][class_selections][class_starting_date]=[field_c_date_value]

The question mark and the equal sign are being escaped and are rendered as %3F and %3E, respectively. This doesn't work.

Anyone know how to get around this problem?

Much thanks,
Curt

Joined: 10/18/2008
Interesting, I've never used

Interesting, I've never used the prepopulate module. But sounds like your textfield is running through a filter. Might want to use FULL HTML.

/ * Begin Signature */
It's a strange thing about determined seekers-after-wisdom that, no matter where they happen to be, they'll always seek that wisdom which is a long way off. Wisdom is one of the few things that looks bigger the further away it is.

Joined: 09/09/2008
Sometimes you just have to write a little code

I solved this problem.

Undoubtedly, the problem is a filter somewhere, probably within the bowels of views. In this case I think the filter is designed to be a little over aggressive, or conservative. This field starts as a date. In the view I rewrite the value as a link. Since I, the site administrator, am responsible for how it gets rewritten I don't see the need for this aggressive filtering, but I really don't want to go down this line.

Here's the solution: Using Views Theme Information facility I got a list of applicable tpl.php files that I could use. I chose the most specific, views-view-field--view-courses--page-2--field-c-date-value.tpl.php, although I think I'll eventually rename this to use it with another version of this view. Here's the code, inelegant as it is:

<?php $output = str_replace ( "%5B" ,"[", $output );
     
$output = str_replace ( "%5D" ,"]", $output );
     
$output = str_replace ( "%3F" ,"?", $output );
     
$output = str_replace ( "%3D" ,"=", $output );
      print
$output; ?>

Along the way I learned a few lessons that may help others:

  • Views' Rescan template files doesn't always seem to work. I don't know what causes this and found it very frustrating.
  • You put your template files in your theme's directory, not in a subdirectory of the views module.
  • You can, and probably should, create a directory in your theme's directory named "views" to simplify keeping track of these files and protecting them from updates.

Hopefully this information will save someone else the frustration I experienced.

Happy coding,
Curt