Provides a formalized way to declare and suggest page templates using "Template Whisperer".

It is a continuation to something besides the standard node.html.twig file for a variety of special case pages like the site news lists, the contact page, ...

You need Template Whisperer if

  • You want to generate a specific template of a node
    Eg. node--article--xyz.html.twig.
  • You want to allow the editors to freely include pre-defined content on the node by themselves. E.g. Add a list of the three latest news at the end of the content.
  • You want to allow your user(s) to manage by themself all the special pages.
    Eg. The node that list the news by creating the suggestion node--page--news.html.twig.
  • You don't want to hardcode node ID for specific templating but want the content to drive this decision.
  • You don't want to hardcode/configure node url to render blocks (default behavior of Drupal Layout) in a custom template (may need Bamboo Twig).
  • You want Pathauto be able to detect which page list your specific content to generate a real dynamic pattern driven by content creation. Eg. node of type article need a Pathauto patterns /articles/[node:title], you can then use [suggestion:lookup:articles_collection:entity:url:path]/[node:title].

Template Whisperer can do a lot more than that, but those are some of the obvious uses of Template Whisperer.

Features

  • An administration interface to manage Templates Whisperers.
  • Use of standard fields for entity support, allowing for translation and revisioning of Templates Whisperers values added for individual entities.
  • Use of standard fields for entity support, allowing for translation and revisioning of Template Whisperer values added for individual entities.
  • Highly versatile URLs patterns with Template Whisperer Tokens in Pathauto.
  • High permissions granularity:
    • administer template whisperer suggestion entities: Access the administration forms for CRUD operations on Suggestion(s).
    • administer the template whisperer field: Allow to see & edit any Template Whisperer field(s).

Standard usage scenario

Check out the official documentation for a complete guide.

  1. Install the module.
  2. Open admin/structure/template-whisperer.
  3. Create your own suggestion by clicking on "Add Template Whisperer.
  4. Attach a new field "Template Whisperer" for a specific entity.
    1. Go to the "Manage fields" of the bundle where he Template Whisperer field is to appear.
    2. Select "Template Whisperer" from the "Add a new field" selector.
    3. Fill in a label for the field, e.g. "Template Whisperer", and set an appropriate, machine name, e.g. "template_whisperer".
    4. Click the "Save and continue" button.
    5. If the site supports multiple languages, and translations have been enabled for this entity, select "Users may translate this field" to use Drupal's translation system.
  5. When you edit the content of that entity or bundle you should then see the new "Template Whisperer" section on the Advanced tabs.')
    1. Select the suggestion you want to add for that entity or bundle
    2. You can now have access to your own suggestion such [entity-type-id]--[entity-type]--list-news.html.twig.

Which version should I use?

Template Whisperer is only available for both Drupal 8, Drupal 9, Drupal 10 and Drupal 11 (dev)!

Drupal Core Template Whisperer
8.0.x 1.x
8.4.x 2.x
8.8.x 3.x
9.x 3.x
10.x 4.0.x
11.x (dev) 4.0.x

Dependencies

The Drupal version of Template Whisperer requires nothing ! Feel free to use it.

Template Whisperer requires PHP 7.0+ to works properly. We recommend updating to at least PHP 8.0 if possible, and ideally PHP 8.1.

Join Our Drupal Slack Channel



Supporting organizations

This project is sponsored by Antistatique. We are a Swiss Web Agency, Visit us at www.antistatique.net or Contact us.

Known issues

  • In order to uninstall the module any "Template Whisperer"
    fields must first be removed from all entities.
    In order to see whether there are fields blocking the
    module from being uninstalled, load the module uninstall page
    (admin/modules/uninstall) and see if any are listed, it will look something
    like the following:
    The Template Whisperer field type is used in the following field:
    node.field_template_whisperer
    In order to uninstall the module, go to the appropriate field settings pages
    and remove the Template Whisperer field listed in the message. Once this is done it will
    be possible to uninstall the module.
  • In order to uninstall the module any "Template Whisperer"
    entities must first be removed.
    In order to see whether there are entities blocking the
    module from being uninstalled, load the administration interface page
    (admin/structure/template-whisperer) and see if any are listed.
    In order to uninstall the module, delete every entities.
    Once this is done it will be possible to uninstall the module.
Supporting organizations: 

Project information

Releases