Views Exposed form in block : how to add a ajax results counter? I implemented a view as following :


a page display with an extensive exposed filters form (Better exposed filters), ajax enabled, let's call it the landing page
a clone of it, in a second page display with exactly the same fields, but few exposed filters instead (quick search form)
that clone has exactly the same path, Exposed form in block is set to yes


I display the clone created block (quick search form) on homepage : submitting its form redirects to landing page with correct results and the complete exposed filters. This is fine.

Question :

I need to display a results count next to the exposed form block, which refreshes each time you change a exposed filter value in the form.

The Global: Result summary in header or footer doesn't work because  footer and header aren't displayed together with the exposed block, they only come with the full view display.

How could solve that, either with UI or programmatically ? Below some ideas to begin, there might be a good and straight way :


force the results count header to be displayed next to exposed block ?
add a markup to the form with ajax results ?
create another block ?


EDIT

I tried several approaches based on Shreya answer below, but the blocking point is always the same, I need to execute the view to get result count, but as soon as I do, it returns an Allowed memory size exhausted.

in template.php :

function shoot_preprocess_views_exposed_form(&amp;$vars){

  if($vars['form']['#id'] == 'views-exposed-form-customer-products-list-search-block') {
    $view = views_get_view('MY_VIEW');
    $view-&gt;set_display('MY_DISPLAY');
    $view-&gt;execute();
    $count = count( $view-&gt;result );
    $vars['count'] = $count;
  }
}


in views-exposed-form--MY_VIEW.tpl.php

print 'There are:'. $count. 'results'; 


And other tries with views_get_current_view() or views_get_view_result() in the tpl, also tried within form alter :

function MYMODULE_form_views_exposed_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if($form['#id'] == 'views-exposed-form-my-view-my-display') {
    $view = views_get_view('MY_VIEW');
    $view-&gt;set_display('MY_DISPLAY');
    $view-&gt;get_total_rows = true; 
    $view-&gt;pre_execute(); 
    $view-&gt;preview('MY_DISPLAY');
    $view-&gt;execute(); 
    $content = $view-&gt;total_rows; 
  }
  $form['submit']['#value'] = 'Voir les'. $content.' résultats';
}


Any clue to explain why I can't execute the view, or how to return count in that context ?
Create a folder structure as sites/all/themes/example_theme/templates/views 


2.Create a file named views-exposed-form.vars where you use MYTHEME_preprocess_views_exposed_form. Code snippet below:

function example_theme_preprocess_views_exposed_form(&amp;$vars){
  if($vars['form']['#id'] == 'views-exposed-form-exaample-page') {
    $views_rows = views_get_view_result('my_custom_view', 'page');
$count_rows = count($views_rows);
   $vars['count'] = $count_rows;
  }

}



Then you can override the exposed filter tpl. To override the
exposed form template for a particular view, you need to create a
template in the following name pattern,

views-exposed-form--view_name.tpl.php

and print the $count variable wherever you want to place the count.
Once you add the template clear the cache.