Last active
August 29, 2015 14:16
-
-
Save henrytran9x/24dd5c41c8934e58f7ad to your computer and use it in GitHub Desktop.
Show amount of results for exposed filter Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mymodule_form_alter(&$form, &$form_state, $form_id) { | |
switch($form_id){ | |
case 'views_exposed_form': | |
foreach ($form['field_marka_prochnosti_tid']['#options'] as $tid => &$value) { | |
$query = db_select('field_data_field_marka_prochnosti', 'f') | |
->condition('f.field_marka_prochnosti_tid', $tid); | |
$query->addExpression('COUNT(*)'); | |
$count = $query->execute()->fetchField(); | |
$value = $value . ' (' . $count . ')'; | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment