diff --git a/ds.module b/ds.module
index 6f76828..f744c68 100644
--- a/ds.module
+++ b/ds.module
@@ -480,16 +480,17 @@ function ds_preprocess_ds_layout(&$variables) {
/**
* Implements hook_theme_suggestions_alter().
+ *
+ * Note: Alter _ds_field_ui_table_layouts_preview if altering this function
*/
function ds_theme_suggestions_alter(&$suggestions, $variables, $base_theme_hook) {
if (isset($variables['content']) && is_array($variables['content']) && isset($variables['content']['#ds_configuration']) && $base_theme_hook != 'ds_entity_view') {
- $layout_id = $variables['content']['#ds_configuration']['layout']['id'];
$entity_id = $variables['content']['#' . $variables['content']['#entity_type']]->id();
- $suggestions[] = $layout_id . '__' . $variables['content']['#entity_type'];
- $suggestions[] = $layout_id . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#view_mode'];
- $suggestions[] = $layout_id . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#bundle'];
- $suggestions[] = $layout_id . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#bundle'] . '_' . $variables['content']['#view_mode'];
- $suggestions[] = $layout_id . '__' . $variables['content']['#entity_type'] . '__' . $entity_id;
+ $suggestions[] = $base_theme_hook . '__' . $variables['content']['#entity_type'];
+ $suggestions[] = $base_theme_hook . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#view_mode'];
+ $suggestions[] = $base_theme_hook . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#bundle'];
+ $suggestions[] = $base_theme_hook . '__' . $variables['content']['#entity_type'] . '_' . $variables['content']['#bundle'] . '_' . $variables['content']['#view_mode'];
+ $suggestions[] = $base_theme_hook . '__' . $variables['content']['#entity_type'] . '__' . $entity_id;
}
}
diff --git a/includes/field_ui.inc b/includes/field_ui.inc
index e86d01b..9493268 100644
--- a/includes/field_ui.inc
+++ b/includes/field_ui.inc
@@ -867,15 +867,18 @@ function _ds_field_ui_table_layouts_preview(array &$form, FormStateInterface $fo
$chosen_layout = $ds_layouts[$layout_string];
$selected = '' . $chosen_layout['label'] . '';
$selected .= '
' . t('The default template can be found in %path', array('%path' => $chosen_layout['template_path']));
+
+ /** @see ds_theme_suggestions_alter */
$suggestions_array = array();
- $suggestions_array[0] = $layout_string . '--' . $display->getTargetEntityTypeId();
- $suggestions_array[2] = $layout_string . '--' . $display->getTargetEntityTypeId() . '-' . $display->getTargetBundle();
- $suggestions_array[4] = $layout_string . '--' . $display->getTargetEntityTypeId() . '--{id}';
+ $suggestions_array[0] = $chosen_layout['template'] . '--' . $display->getTargetEntityTypeId();
+ $suggestions_array[2] = $chosen_layout['template'] . '--' . $display->getTargetEntityTypeId() . '-' . $display->getTargetBundle();
+ $suggestions_array[4] = $chosen_layout['template'] . '--' . $display->getTargetEntityTypeId() . '--{id}';
if ($display->getMode() != 'default') {
- $suggestions_array[1] = $layout_string . '--' . $display->getTargetEntityTypeId() . '-' . $display->getMode();
- $suggestions_array[3] = $layout_string . '--' . $display->getTargetEntityTypeId() . '-' . $display->getTargetBundle() . '-' . $display->getMode();
+ $suggestions_array[1] = $chosen_layout['template'] . '--' . $display->getTargetEntityTypeId() . '-' . $display->getMode();
+ $suggestions_array[3] = $chosen_layout['template'] . '--' . $display->getTargetEntityTypeId() . '-' . $display->getTargetBundle() . '-' . $display->getMode();
}
+
ksort($suggestions_array);
// Append correct extension.