You are here

function field_group_theme_registry_alter in Field Group 7

Same name and namespace in other branches
  1. 8.3 field_group.module \field_group_theme_registry_alter()
  2. 8 field_group.module \field_group_theme_registry_alter()
  3. 7.2 field_group.module \field_group_theme_registry_alter()

Implements hook_theme_registry_alter().

File

./field_group.module, line 198
Fieldgroup module.

Code

function field_group_theme_registry_alter(&$theme_registry) {

  // Inject field_group_build_entity_groups in all entity theming functions.
  $entity_info = entity_get_info();
  $entities = array();
  foreach ($entity_info as $entity => $info) {
    if (isset($entity_info[$entity]['fieldable']) && $entity_info[$entity]['fieldable']) {

      // User uses user_profile for theming.
      if ($entity == 'user') {
        $entity = 'user_profile';
      }
      $entities[] = $entity;
    }
  }

  // Support for File Entity.
  if (isset($theme_registry['file_entity'])) {
    $entities[] = 'file_entity';
  }

  // Support for Entity API.
  if (isset($theme_registry['entity'])) {
    $entities[] = 'entity';
  }
  foreach ($entities as $entity) {
    if (isset($theme_registry[$entity])) {
      $theme_registry[$entity]['preprocess functions'][] = 'field_group_build_entity_groups';

      // DS support, make sure it comes after field_group.
      if ($key = array_search('ds_entity_variables', $theme_registry[$entity]['preprocess functions'])) {
        unset($theme_registry[$entity]['preprocess functions'][$key]);
        $theme_registry[$entity]['preprocess functions'][] = 'ds_entity_variables';
      }
    }
  }
}