You are here

exposed_filter_data.module in Exposed Filter Data 7

Same filename and directory in other branches
  1. 8 exposed_filter_data.module
  2. 6 exposed_filter_data.module

Provides simple way to print exposed filter data

File

exposed_filter_data.module
View source
<?php

/**
 * @file
 * Provides simple way to print exposed filter data
 */

/**
 * Implementation of hook_theme().
 */
function exposed_filter_data_theme() {
  return array(
    'exposed_filter_data' => array(
      'template' => 'exposed_filter_data',
      'variables' => array(
        'view' => NULL,
      ),
    ),
  );
}

/**
 * Implementation of hook_preprocess().
 */
function exposed_filter_data_preprocess_exposed_filter_data(&$vars) {

  // Add the CSS
  drupal_add_css(drupal_get_path('module', 'exposed_filter_data') . '/exposed_filter_data.css');
  $view = $vars['view'];

  // In case no view - get the current view
  if ($view == NULL) {
    $view = views_get_current_view();
  }

  // Make a variable out of each filter
  if (isset($view->exposed_input)) {
    foreach ($view->exposed_input as $filter => $value) {
      $vars[$filter] = $value;
      if (is_array($value)) {
        $vars['exposed_filters'][$filter] = check_plain(implode(", ", $value));
      }
      else {
        $vars['exposed_filters'][$filter] = check_plain($value);
      }
    }
  }
}

/**
 * Simple call to the theme, easy to be used in a view header
 *
 */
function get_exposed_filter_output() {
  return theme('exposed_filter_data');
}

Functions

Namesort descending Description
exposed_filter_data_preprocess_exposed_filter_data Implementation of hook_preprocess().
exposed_filter_data_theme Implementation of hook_theme().
get_exposed_filter_output Simple call to the theme, easy to be used in a view header