The Issue here is that when filtering a Drupal 6 view using an argument the block filter selection does not match the argument.
View configuration
View accepts a single argument derived from a CCK field select list widget.
Filter is exposed as a block.
Filter block also includes the same CCK field as referenced in the argument.
In the snippet below 'field_make_value_many_to_one' is the name of the form select item that you want to match to your argument.
function mymodule_form_alter(&$form, $form_state, $form_id)
{
// function seems to get called twice so need to cache
static $term;
switch($form_id) {
// issue:
// when filter view using argument the
//exposed filter block selection does not
// match the argument
//
// we want to modify the form select element selection state
case 'views_exposed_form':
// take a peek
// dvm($form_state['view'], 'hook_form_alter');
// change the button text
$form['submit']['#value'] = 'Search';
// get the view argument if defined
$term_arg = $form_state['view']->args[0];
if (isset($term_arg)) {
$term = $term_arg;
}
// change our input as required
if (isset($term)) {
$form_state['input']['field_make_value_many_to_one'] = $term;
}
break;
}
}
Fri, 03/26/2010 - 07:47
This is a great solution for making the exposed filters match the arguments, but there is one drawback. When the exposed filters form is submitted, the results are now filtered by both the argument (which remains intact) and the filter form.
I'm hoping to find a way to have the exposed filters either create a URL using arguments instead of URL encoded variables or to have the form override the arguments and reduce the URL to the views base path.
Thanks for the post.
»
Fri, 06/18/2010 - 16:57
I am also looking for a way to solve this issue :
filtering on both args and exposed filters for the same terms
did you have any progress or ideas on how to avoid that?
I need to provide a list of links with preset arguments, but then if my user uses the exposed filters there are no results (conflict of args and filters...)
ideally we should be able to make the exposed filter form to post arguments and not keys where applicable.
thanks!
Vas
»
Post new comment