There is a content type and it has a field called field_type. It's a select list and there is 5 options to select such as AAA, BBB, CCC, DDD, EEE.

I'm using the Views module to list the nodes of this content type. I added the field_type as exposed filter for this views.

In the header of the views, I added the Global: Result summary to show result summary.

 "@total results found."

enter image description here

What I want to do is dynamically change the text based on the exposed filter. For example if the AAA is selected on the field_type exposed filter then the results summary should display:

 "@total AAA found."

How can I do that?

  • Did you have a chance to try out the module I posted? I believe it answers your question and solves your problem. You can install it as a you would with any other contrib module. Cheers Feb 16, 2016 at 8:10

2 Answers 2


This can be done by implementing the hook_views_pre_render and altering the view's header content. Here is a sample code:

 * Implements hook_views_pre_render().
function my_module_views_pre_render(&$view) {
  if ($view->name == 'my_view' && $view->current_display == 'my_display') {
    $indicator = $view->exposed_input['my_filter'] == 1 ? t('AAA ') : t('BBB ');
    $view->header['result']->options['content'] = '<div class="my-class-results">@total <strong><em>' . $indicator . '</strong></em> found</div>';

This works with any substitution: @start, @end, @total, @name etc


I took the liberty of writing a little module for accomplishing what you asked for, I found it an interesting problem. You can access it here:


Hope this helps

  • Thanks for your answer and for the "sandbox" module. I have to learn how to use this kind of modules :)
    – herci
    Feb 13, 2016 at 21:23
  • Do give it a try and please let me know if you have any questions. Feb 13, 2016 at 22:51
  • Unfortunately it gives some error. I will try to solve the errors myself, if I couldn't I will write them here. Thanks.
    – herci
    Feb 16, 2016 at 11:45
  • Hello @herci. Did you get this to work? What is the problem you are facing with installing this module? Cheers Mar 2, 2016 at 23:06

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.