Drupal’s template hierarchy gives themers the power to define the look and feel of nodes. This allows content creators to focus on the content while Drupal handles how it is displayed.
But sometimes it would be nice to provide a way for the content creators themselves to pick between predefined displays of their content, like this:
(...personally, I like option 2)
You could probably do this with Panels or Display Suite, but those tools may be overwhelming for content creators. You could do custom development by adding some fields and custom logic, but it takes some Drupal development chops, and if you aren’t careful, you’ll end up with code spread across modules and themes, or dependencies on configuration that may or may not be in version control.
Enter Template Picker.
I built Template Picker to give content creators a choice over which template to use for a piece of content, using a simple select box (shown in the image below, on the right). The box contains a “default” option, which uses the standard template suggestion, or you can add additional options by naming your new templates (shown below, on the left) according the the template picker naming convention: node–content-type–tp*.tpl.php.
This makes adding new options as simple as duplicating an existing template, renaming it, and making the desired changes to the html/css. It keeps the codebase clean, eliminates dependencies, and it’s so easy that anyone with a little front-end experience can do it.
If you have any experience with Wordpress, this concept may be familiar. Functionality like this has been a part of core Wordpress for their page templates for a while, and this is an attempt to provide a similar experience in Drupal.
Template picker also supports clean names, which let you rename items in the select list so content creators can know what they are picking. To create a clean name for a template, just add a line of code into the template’s comments (as shown circled below):
This early version of template picker works for node templates on all your content types, but if there is interest in expanding the tool, we could also add support for block templates, and possibly more.