Theming
Last updated on
22 July 2019
The Permanent Entities modules provides a set of theme hook suggestions to help you theme the content created by this module. The code that creates the theme suggestions is this:
/**
* Implements hook_theme_suggestions_HOOK().
*/
function permanent_entities_theme_suggestions_permanent_entity(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#permanent_entity'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'permanent_entity__' . $sanitized_view_mode;
$suggestions[] = 'permanent_entity__' . $entity->bundle();
$suggestions[] = 'permanent_entity__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'permanent_entity__' . $entity->id();
$suggestions[] = 'permanent_entity__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
Examples:
Assuming you have a planets type with jupiter as available entity ids and a view mode called teaser. The list of available templates are:
permanent_entity.html.twigpermanent_entity--teaser.html.twigpermanent_entity--planets.html.twigpermanent_entity--planets--teaser.html.twigpermanent_entity--jupiter.html.twigpermanent_entity--jupiter--teaser.html.twig
In case your entity name has some underscore on it, for example: sea_water the template name will replace the underscore with an hyphen. i.e. permanent_entity--sea-water.html.twig
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion