6

I'm using views 3 with drupal 7.

I have a views page listing content of a certain content type 'Clothes'. I have a exposed form(in a block) that filters this list by size(small,medium,large) and color(red,blue).

When I click submit, is it possible to show in the header of my results page like the following?

Showing results for Small size and Red color:

3 Answers 3

1

Yes, ultimately all the filters send the data using HTTP methods GET/POST. If you are not using AJAX with views then HTTP method GET is used to send the data.

To display the information in header add Global:Custom Text field and add below line in it.

<div>Showing results for $_GET[X] size and $_GET[Y] color.</div>

Where : X - name of size field Y - name of color field You will get the names from the url generated after search in address bar.

0

I'm not aware of a simple way of doing this with exposed filters. Contextual filters, or arguments, on the other hand, have an option for this, that allows you to use tokens to set the title like

Showing results for [size] size and [color] color

but that would on the other hand require you to find a different way of showing the exposed filters.

The easiest way I can think of to solve this, is to have both exposed and contextual filters. After that a form submit hook could do

$path_to_view = 'store/';
drupal_goto($path_to_view . $_GET['id_of_filter_1'] . '/' . $_GET['id_of_filter_2']);

to create a redirect from the exposed filters to the contextual ones. This way you could get the best of both worlds.

0

I don't know whether this will help you or not but you can try this, For the title of the expose filter result you can try to add in between Global: Result summary or Global: Text area from add header and the expose filter call the views_exposed_form on result use the

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id=='views_exposed_form')
    {
        $form['#submit'][] = 'call_ur_form_state_function';
    }   
}

function call_ur_form_state_function($form, &$form_state){
    //dpm($form_state);
}

to alter the $form_state value, there you will get the all array and object of the current view to alter, by this way probably you can reconstruct your string for output page.

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.