You are here

function select2widget_preprocess in Select2 Field Widget 7.2

Implements hook_preprocess().

File

./select2widget.module, line 392

Code

function select2widget_preprocess(&$variables, $hook) {
  switch ($hook) {
    case "node":
      if (!empty($variables['node']->select2widget)) {
        $variables['theme_hook_suggestions'][] = "node__select2widget";
        $variables['theme_hook_suggestions'][] = "node__" . $variables['type'] . "__select2widget";
        $variables['theme_hook_suggestions'][] = "node__" . $variables['type'] . "__select2widget__" . $variables['view_mode'];
      }
      break;
    case "user_profile":
      if (!empty($variables['elements']['#account']->select2widget)) {
        $variables['theme_hook_suggestions'][] = "user_profile__select2widget";
        if (isset($variables['elements']['#entity_view_mode']['view_mode'])) {
          $variables['theme_hook_suggestions'][] = "user_profile__select2widget__" . $variables['elements']['#entity_view_mode']['view_mode'];
        }
        if (isset($variables['elements']['#account'])) {
          $variables['account'] = $variables['elements']['#account'];
        }
      }
      break;
  }
}