How to modify URL queries passed to view before its processed?

glass.dimly - June 14, 2009 - 19:59

So I've got a view that has takes a filter from an exposed form. The form doesn't pass the values gathered to the URL args, instead, it passes it as a query string to the URL. I need to ensure that this value is not over a certain number.

This is what the URL looks like:
http://forpeace.mayfirst.org/for-chapters-by-zip?distance[postal_code]=60626&distance[search_distance]=200&distance[search_units]=mile

This: ?distance[postal_code]=60626&distance[search_distance]=200&distance[search_units]=mile is not written to the args.

I need to ensure that the value passed to the view does not exceed 3285 miles because of this bug: http://drupal.org/node/471040

Any idea how to edit URL values before they are processed by the view?

I guess you could do it by

marcvangend - June 14, 2009 - 20:21

I guess you could do it by implementing a hook like hook_views_pre_build, but I'm not 100% sure if it's possible and which hook you should use. See http://views.doc.logrus.com/group__views__hooks.html for a list of available hooks. Please follow up with your solution when you figure it out, I'd like to know!

Solution

glass.dimly - June 15, 2009 - 04:13

Thanks for the docs link. I managed this by modifying the $GLOBAL variables inside a view template file.

http://drupal.org/node/471040 comment #3.

Thanks fot the follow up, I

marcvangend - June 15, 2009 - 08:09

Thanks fot the follow up, I didn't think of that solution. It feels a little hackish, but I guess that's allowed when you're doing a quick workaround for a bug :-)

Well....

glass.dimly - June 15, 2009 - 14:17

...that's true, I'd prefer a more Drupalish way, but how can one get at the URL string if not through the $GLOBALS if it's not being written to the args?

Anyone?

I wouldn't worry about it,

marcvangend - June 15, 2009 - 14:50

I wouldn't worry about it, because the true problem is in the location module, not in the variables. The Drupalish way is to help fix the module and that's what you're doing.

 
 

Drupal is a registered trademark of Dries Buytaert.