Download the PHP package drupal-generics/entity_theme_suggestions without Composer
On this page you can find all versions of the php package drupal-generics/entity_theme_suggestions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drupal-generics/entity_theme_suggestions
More information about drupal-generics/entity_theme_suggestions
Files in drupal-generics/entity_theme_suggestions
Package entity_theme_suggestions
Short Description Provides theme suggestions plugin for all type of entities.
License GPL-2.0+
Informations about the package entity_theme_suggestions
Entity Theme Suggestions
This module provides a plugin which can define new theme suggestions for entities. It replaces hook_theme_suggetions_alter(). The module provides a base suggestions class, "EntityThemeSuggestionsBase", that can be extended by any plugin so that it inherits the most common theme suggestions.
Usage
Create a class in "Plugin/ThemeSuggestions" directory structure of your module, that implements "EntityThemeSuggestionsInterface" interface. The "alterSuggestions" function should return all the theme suggestions for your entity.
To mark your class as an entity theme suggestions plugin, you have to add an annotation:
The plugin id is required and has to be unique. The entity type is required also. The priority field is optional and set to 1 by default.
Example:
This code creates the provided default suggestions from the module for the user entity. The suggestions are defined in the base class by the "alterSuggestions()" method. The method provides the following suggestions:
- [entity_type_id]
- [entity_type_id]--[view_mode]
- [entity_type_id]--[bundle]
- [entity_type_id]--[bundle]--[view_mode]
- [entity_type_id]--[entity_id]
- [entity_type_id]--[entity_id]--[view_mode];