View Mode Templates

Categories

Component ID

1759210

Component name

View Mode Templates

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

5198

Component created

Component changed

Component body

Lets you create entity view mode templates as ENTITY-TYPE--BUNDLE--VIEW-MODE.tpl.php. Templates can be used in custom themes and modules.

Theme

Create ENTITY-TYPE--BUNDLE--VIEW-MODE.tpl.php template and it will be picked up automatically.

Module

1. Implement hook_view_mode_templates() as follows. This hook should return a list of templates you want to use in the module.

/**
 * Implements hook_view_mode_templates().
 */
function MODULE_view_mode_templates() {
  return array(
    'node__article__teaser',
    'node__article__full',
    'taxonomy_term__tags__full',
  );
}

2. Create the templates inside a templates directory inside your custom module. That's it.