Views custom template
Version 7.x-1.0 is deprecated in favor of version 7.x-2.0
What is Views custom template?
Views custom template allows you to add a template suggestion for view displays, rows and fields so you can re-use one template for multiple views
This allows you to create and reuse a single template. Instead of copying (and duplicating) a template, stay DRY.
Version 7.x-2.0
See documentation
Version 7.x-1.0
The module extends the Views Fields display, so you can still assign fields and alter them using standard Views options: links, labels, booleans etc. The resulting template will have a $content
variable available that contains an object with the mapped fields by field name.
Template function
Views resolves which template to use via theme hooks. This module adds 1 theme hook that starts with custom_template__
. You don't include that part in the Template function field. The template file will have to include that part though:
- Template function:
event_block
- Preprocessors:
hook_custom_template
andhook_custom_template__event_block
- Template file:
custom-template--event-block.tpl.php
Field name mapping
Since several Views and Views displays can end up in a single template, it might contain different field names. (It might even contain different fields.) Instead of coding inside the template, or having a huge row preprocessor, this module allows for field name mapping. You can specify the target name for every field, so that the template can depend on predictable field names.