- π³π±Netherlands askibinski
As commented here: #2862910: Add template suggestions to twig debug β the normal views suggestions do work. However, it's true that twig debug does not actually show these in the html comments.
That might be related to this core issue though.
π [PP-1] Use hook_theme_suggestions in views Postponed - πΊπΈUnited States mlncn Minneapolis, MN, USA
EVA is also somehow not producing field template suggestions on the node it is attached to. Say there are multiple EVAs on a content type, these are reorderable at Manage display, "EVA Example One", "EVA Example Two", "EVA Example Three". When output however in the template there is no distinction.
Where a regular field would have a suggestion such as
field--node--example-field.html.twig
, an EVA pseudo-field only hascontainer.html.twig
, and then goes toeva-display-entity-view.html.twig
. This latter one should have the hidden Views template suggestions, but having field-level template suggestions in the pseudo-field would be very helpful simply for rearranging and grouping fields in the template.If there were a template suggestion from the pseudo field of
example-eva-entity-view-1
, even if nothing in it, even if not used, it{{ content.example_eva_entity_view_1 }}
The above does work by the way!! The name of the pseudofield comes from the view machine name (
example_eva
in our case above) plus the display machine name (entity_view_1
in our example). - Status changed to Needs review
about 1 year ago 9:45am 14 September 2023 - πͺπΈSpain pakmanlh Barcelona
Just in case someone is trying to make the @prudloff snippet work, here you have what I finally ended up using:
/** * Implements hook_theme_suggestions_HOOK_alter(). */ function foo_theme_suggestions_eva_display_entity_view_alter(array &$suggestions, array $variables) { /** @var \Drupal\views\ViewExecutable $view */ $view = $variables['view']; $suggestions[] = implode('__', [ $variables['theme_hook_original'], $view->id(), ]); $suggestions[] = implode('__', [ $variables['theme_hook_original'], $view->id(), $view->current_display, ]); }
I think there are two different templates / issues, one coming from the Views module directly which as @askibinski rightly mentioned can be override as usual even though the suggestions are not showed up, but also there is another template coming from the EVA module which can be tweaked as the example from above.
Not sure if this should be part of the main module, I am changing the issue status so the maintainers can decide how to proceed.
Thanks!