Skip to content
Snippets Groups Projects
Commit 8371d920 authored by Stephen Mustgrave's avatar Stephen Mustgrave
Browse files

Issue #3166744: Views override

parent 693bf5b4
No related branches found
No related tags found
1 merge request!10Issue #3166744: Views override
Pipeline #18193 passed
......@@ -105,9 +105,8 @@ class RowFieldset {
}
}
}
// @todo Theme hook suggestions!
$element = [
'#theme' => 'views_fieldsets_' . $this->getWrapperType(),
'#theme' => $this->themeFunctions($this->getWrapperType()),
'#fields' => $this->children,
'#show_fieldset' => $show_fieldset,
'#legend' => Markup::create($this->getLegend()),
......@@ -176,4 +175,39 @@ class RowFieldset {
$this->children[$field_name] = $fields[$field_name];
}
/**
* Generate a list of theme hook suggestions.
*
* @param string $type
* Fieldset type.
*
* @return array
* List of theme suggestions.
*/
public function themeFunctions(string $type): array {
$themes = [];
$hook = 'views_fieldsets_' . $type;
$display = $this->handler->view->display_handler->display;
if (!empty($display)) {
$themes[] = $hook . '__' . $this->handler->view->storage->id() . '__' . $display['id'] . '__' . $this->handler->options['id'];
$themes[] = $hook . '__' . $this->handler->view->storage->id() . '__' . $display['id'];
$themes[] = $hook . '__' . $display['id'] . '__' . $this->handler->options['id'];
$themes[] = $hook . '__' . $display['id'];
if ($display['id'] != $display['display_plugin']) {
$themes[] = $hook . '__' . $this->handler->view->storage->id() . '__' . $display['display_plugin'] . '__' . $this->handler->options['id'];
$themes[] = $hook . '__' . $this->handler->view->storage->id() . '__' . $display['display_plugin'];
$themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->handler->options['id'];
$themes[] = $hook . '__' . $display['display_plugin'];
}
}
$themes[] = $hook . '__' . $this->handler->view->storage->id() . '__' . $this->handler->options['id'];
$themes[] = $hook . '__' . $this->handler->view->storage->id();
$themes[] = $hook . '__' . $this->handler->options['id'];
$themes[] = $hook;
return $themes;
}
}
......@@ -245,3 +245,18 @@ function views_fieldsets_views_ui_rearrange_form_submit($form, $form_state) {
$display->setOption('fields', $display_fields);
$ui_view->cacheSet();
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function views_fieldsets_theme_suggestions_paragraph(array $variables) {
$suggestions = [];
$paragraph = $variables['elements']['#paragraph'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'paragraph__' . $sanitized_view_mode;
$suggestions[] = 'paragraph__' . $paragraph->bundle();
$suggestions[] = 'paragraph__' . $paragraph->bundle() . '__' . $sanitized_view_mode;
return $suggestions;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment