You are here

function opigno_catalog_preprocess_views_exposed_form__opigno_training_catalog__training_catalogue in Opigno training catalog 8

Implements hook_preprocess_HOOK().

File

./opigno_catalog.module, line 119
Contains opigno_catalog.module.

Code

function opigno_catalog_preprocess_views_exposed_form__opigno_training_catalog__training_catalogue(&$variables) {
  if ($category =& $variables['form']['field_learning_path_category_target_id']) {
    if (empty($category['#title'])) {
      $category['#title'] = t('Categories');
      $category['#title_display'] = 'invisible';
    }
  }
  foreach ($variables['form']['#info'] as $input) {
    $args = $_GET;
    $input_argument = $input['value'];

    // Remove form_argument from url_arguments.
    unset($args[$input_argument], $args['sort_by']);
    foreach ($variables['form'][$input['value']] as $key => &$value) {
      if (is_int($key)) {
        $args[$input['value']] = strval($value['#return_value']);
        $view = Views::getView('opigno_training_catalog');
        $view
          ->setExposedInput($args);
        $view
          ->execute();
        $value['#title'] .= ' (' . $view->total_rows . ')';
      }
    }
  }
}