Node templates by class
This page is for designers who organize the view templates of a whole site. The usual pattern: one override rule and one template for each pair of content class and view mode that needs its own look.
Contents
The pattern
[mytheme_full_article]
Source=node/view/full.tpl
MatchFile=full/article.tpl
Subdir=templates
Match[class_identifier]=article
[mytheme_line_article]
Source=node/view/line.tpl
MatchFile=line/article.tpl
Subdir=templates
Match[class_identifier]=articleFolder layout and names
design/mytheme/override/templates/
├── full/article.tpl full/folder.tpl full/event.tpl
├── line/article.tpl line/event.tpl
├── card/article.tpl
└── embed/image.tpl embed/video.tpl- Folder = view mode; file = class identifier.
- Section names:
<theme>_<mode>_<class>; unique across all settings files. - One rule per pair; no giant switch in a generic template (Switch and case).
Which pairs a site needs
| Class | full | line | card | embed |
|---|---|---|---|---|
| article | yes | yes | yes | |
| folder | yes | yes | ||
| image | yes | |||
| ... |
Fill a table like this from the site's content model; every "yes" is one rule and one template. Classes without a rule
use the default node/view/<mode>.tpl, so make the defaults decent.
How the shipped designs do it
- The media design keeps its rules in
settings/siteaccess/site/override.ini.append.php(andbold/) of its extension, with templates inoverride/templates/full/,line/,embed/,content/and more. - The starter design keeps them in
settings/siteaccess/cjw_starter/override.ini.append.php; eachfull/<class>.tplincludescontent/full/<class>.tpl, so layout blocks can draw parts of the same content. - The super design shows the minimal case: one rule,
full/article.tpl.
Related pages
- Override basics
- View modes
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.