Advertising sustains the DA. Ads are hidden for members. Join today

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.twig
  • permanent_entity--teaser.html.twig
  • permanent_entity--planets.html.twig
  • permanent_entity--planets--teaser.html.twig
  • permanent_entity--jupiter.html.twig
  • permanent_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: