fix for exposed views filters sending you to the homepage of your site

This bug and fix apply to Drupal 6.15, Views 6.x-2.8

This is a buggy litttle bugger for sure.  I had a view that included an exposed filter.  When clicking on the "Apply" button of the exposed filter, I'd get sent to my sites homepage, but with the query string info from the exposed filter.  Needless to say, this was annoying.

I used the HOOK_form_views_exposed_form_alter function (http://api.drupal.org/api/function/hook_form_FORM_ID_alter/6) to alter the action of the form.  I hope this helps somebody out there.

<?php
function HOOK_form_views_exposed_form_alter(&$form , &$form_state){
// Essentially getting the system url
$daArgs = arg();
// Make it into a nice little url
$daArgs = implode("/" , $daArgs);

switch($form['#id']){
case
'views-exposed-form-VIEW-NAME-HERE-default':
// for whatever reason, the short name needs to be used in the function and
// the long name is used in the case...whatever.
$form['#action'] = base_path() . $daArgs . "/";
break;
}
// end switch

}
?>

 

VIEW-NAME-HERE can be found as the last item in the url when you're editing your view, for me it was admin/build/views/edit/content_management and I replaced the '_' with a '-'.  Boom.

-James