You are here

function gridstack_theme_suggestions_gridstack_alter in GridStack 8

Implements hook_theme_suggestions_HOOK_alter().

File

./gridstack.module, line 83
Provides GridStack integration to have multi-column grids with drag-and-drop.

Code

function gridstack_theme_suggestions_gridstack_alter(array &$suggestions, array $variables) {
  $settings = isset($variables['element']['#settings']) ? $variables['element']['#settings'] : [];
  if (!empty($settings['root']) && !empty($settings['optionset'])) {
    $suggestions[] = 'gridstack__' . $settings['optionset'];

    // This currently applies to DS only.
    // @todo: Make this work for field formatters, and Views style plugin.
    if (!empty($settings['extras']) && isset($settings['extras']['bundle'])) {
      $extras = $settings['extras'];
      $suggestions[] = 'gridstack__' . $extras['entity_type'];
      $suggestions[] = 'gridstack__' . $extras['entity_type'] . '_' . $extras['bundle'];
      $suggestions[] = 'gridstack__' . $extras['entity_type'] . '_' . $extras['bundle'] . '_' . $extras['view_mode'];
      $suggestions[] = 'gridstack__' . $extras['entity_type'] . '_' . $extras['bundle'] . '_' . $settings['optionset'];
    }
  }
}