Glossary

Fluid

The template language of TYPO3. It decides how data is turned into HTML.

What Fluid does

Fluid turns data into HTML. It receives variables, a record or a list for instance, and outputs markup. The syntax uses curly braces for variables and tags of its own for everything else.

The principle is deliberately plain. A template should stay readable, including for somebody who does not write PHP.

ViewHelpers

Where plain output is not enough, ViewHelpers come in. They are small, reusable building blocks for jobs such as creating links, processing images, formatting numbers or shortening text.

TYPO3 ships with a great many of them. Writing your own makes sense when a particular piece of presentation logic keeps recurring in a project. They are the right home for anything that would otherwise end up as an impenetrable nest in the template.

Working with TypoScript

Fluid and TypoScript share the work. TypoScript decides which template is responsible for which case and what data is handed in. Fluid decides how that data is presented.

When something goes wrong, that split is the first useful diagnosis. If a variable is missing in the template, the cause usually sits in TypoScript or in the controller, not in the template itself.

In the sitepackage

The Fluid files of a project live in the sitepackage, separated into templates, layouts and partials. That structure is a convention, and it is worth keeping even on small projects, because it does not have to be rebuilt as things grow.

Common questions

What is the difference between a template, a layout and a partial?

A template belongs to one particular output, such as the detail view of a record. A layout describes the frame that stays the same around several templates. A partial is a reusable section included in several places.

The split pays off as soon as something is needed a second time. A partial used in five places only has to be changed once.

Is logic allowed in a template?

As little as possible. Fluid can do conditions and loops, and that is enough for questions of presentation: show something or not, walk through a list, set a class depending on a value.

Anything that makes a decision about data belongs earlier: in the controller, in a ViewHelper or in the data model. Templates with nested conditions are hard to test and harder still to change.

Terms used on this page

Templates that resist every change?

When a small adjustment breaks something in three other places, the wish is rarely the problem. We will sort out the templating layer.