You are here

function global_filter_get_field_instances in Views Global Filter 8

Same name and namespace in other branches
  1. 7 global_filter.widgets.inc \global_filter_get_field_instances()

Get field instances.

2 calls to global_filter_get_field_instances()
global_filter_create_widget in ./global_filter.widgets.inc
Based on the requested or field-implied widget.
_global_filter_configure_form in ./global_filter.blocks.inc
Generates the filter configuration form for filters in a block.

File

./global_filter.widgets.inc, line 414
global_filter.widgets.inc

Code

function global_filter_get_field_instances($field_name) {
  $instances = array();
  foreach (field_info_instances() as $entity_type => $type_bundles) {

    // Example: $entity_type == 'file', 'node', 'taxonomy_term' or 'user'
    // $bundle == 'article' or 'user'
    foreach ($type_bundles as $bundle => $bundle_instances) {

      // Fields of node, user.
      foreach ($bundle_instances as $f_name => $instance) {
        if ($f_name == $field_name) {
          $instances[] = $instance;
        }
      }
    }
  }

  // If the field has instances with different widgets, prefer 'node' over
  // 'taxonomy_term' or 'user' and with 'node' prefer field names that come
  // earlier in the alphabet.
  return array_reverse($instances);
}