Introduction to Tripal Templates

Page Sections

How Modules Provide Content

Tripal modules are responsible for creating Drupal nodes (pages) that correspond to a major data type in Chado.  For example, the Tripal Feature module creates nodes for features stored in Chado. The Tripal Stock module creates nodes for stocks stored in Chado.  Other node types include libraries (Tripal  Library module), analyses (Tripal Analysis module), projects (Tripal Project module), publications (Tripal Pub module) and more.  Each of these modules generates the display for the data managed.  For example, the Tripal Feature module provides CSS, JavaScript and PHP template files that display all information about features as stored in Chado. Template files are special PHP files that are meant to be editable by a site developer to customize the site.

Tripal 2.x Theme Changes

In previous versions of Tripal, a separate Tripal theme was available that contained all of the template files.  Tripal users were required to download and install Tripal and also download and install the Tripal Theme.  The Tripal theme was a "base" theme and required a few configuration steps so that it would interact with the site's default theme.  For Tripal 2.x this has changed.  There is no longer a seperate Tripal theme.  Now, theme templates are housed directly with the Tripal modules and there are no configuration steps needed to integrate with the site's default theme.

Also, in previous versions of Tripal, the Tripal theme provided a look-and-feel that included two boxes: one that surrounded the main content and a side bar with links to ancillary data.  These boxes had rounded corners in most browsers.   For Tripal 2.x this look-and-feel is simplified.  There are no longer boxes with rounded corners as these do not always match a site's look-and-feel.  All but very minimal styling has been removed to afford better integration with the sites theme.

Theming Files

Tripal modules will always place code for display of data inside of templates files.  These files are written in PHP and use a combination of Drupal API functions, Tripal API functions and HTML.   Template files can always be found within the module directory in the following structure:

[tripal module dir]/theme/templates

CSS, JavaScript, and any images that may be needed for the templates can be found here:

[tripal module dir]/theme/templates/js
[tripal module dir]/theme/templates/css
[tripal module dir]/theme/templates/images

For example, the Tripal Feature module has the following directory tree:

├── css
│   └── tripal_feature.css
├── images
│   ├── type_color1.png
│   ├── type_color2.png
│   ├── type_color3.png
│   ├── type_color4.png
│   ├── type_color5.png
│   └── type_color6.png
├── js
│   └── tripal_feature.js
├── templates
│   ├── tripal_feature_alignments.tpl.php
│   ├── tripal_feature_analyses.tpl.php
│   ├── tripal_feature_base.tpl.php
│   ├── tripal_feature_help.tpl.php
│   ├── tripal_feature_properties.tpl.php
│   ├── tripal_feature_publications.tpl.php
│   ├── tripal_feature_references.tpl.php
│   ├── tripal_feature_relationships.tpl.php
│   ├── tripal_feature_sequence.tpl.php
│   ├── tripal_feature_synonyms.tpl.php
│   ├── tripal_feature_teaser.tpl.php
│   ├── tripal_feature_terms.tpl.php
│   ├── tripal_organism_feature_browser.tpl.php
│   └── tripal_organism_feature_counts.tpl.php

As can be seen above, all template file names include the Tripal module name as a prefix (e.g. "tripal_feature"), followed by the data being handled (e.g. "alignments", "references", "properties", etc.) and finally a ".tpl.php" extension.   Notice the template named "tripal_feature_base.tpl.php."  The "base" template houses the basic information about the data.  For the Tripal feature module, the "base" template houses basic information about the feature such as the organism, type, length, etc., and the other templates provide additional information.  All of these template files can be edited to customize the data that is presented in each.

The "" file seen above contains all of the "preprocess" functions that prepare data for the templates.  This file should not be edited as it is part of the module.