Table of Contents
TYPO3 is known to be a very powerful, yet complex content management system. Although several ready-made templates and even kits for out-of-the-box websites exist for TYPO3, most of the users and developers are attracted by the flexibility and the high degree of freedom TYPO3 allows for the design and functionality of feature-rich websites. For those who want more than a point and click web design with the option to choose from a red or purple background, it is highly recommended to delve into TypoScript.
Since its early versions, TypoScript has been an important factor for the success of TYPO3. A lot of myths exist about what TypoScript is and many people experienced that it can be a thin line between loving and dooming TypoScript. However, TypoScript has proven to be a very effective way of writing down configuration.
For the version 5 of TYPO3, the concept of TypoScript and its syntax has been cleaned up and extended in some aspects. The goal was to achieve more consistency and a predictable, yet more intuitive syntax for TYPO3 veterans and newcomers likewise. If you are already an experienced TypoScript developer, you might want to skip this introduction and rather refer to the chapter “What's new in TypoScript 2.0?”.
Let's start with some basic facts about TypoScript:
TypoScript is a syntax for defining information in a hierarchical structure using simple ASCII text content
TypoScript is not a scripting language. It is comparable to formats like YAML or XML where the semantics is defined by the application and not by format itself.
In the TYPO3 CMS, TypoScript is mainly used as an object definition language for
setting generic configuration options
defining the rendering process for a website
TypoScript avails itself of the Object paradigm and offers an effective syntax for defining objects and their properties. The following code snippet defines a new person and assigns a few properties:
Example 3.1. Defining a Person and its properties
somePerson = Person somePerson.firstName = "John" somePerson.lastName = "Doe"
Although the above example is perfectly valid TypoScript, it doesn't neccessarily mean that it has a meaning within TYPO3 - that depends on the scope where this chunk of TypoScript is used, not on the syntax itself. Here is a more abstract example, still with a valid syntax but probably no meaning at all:
Example 3.2. Meaningless but valid TypoScript
asdf = Qwerty asdf.zxcvbnm = "uiop" asdf.backgroundColor = BLUE
Both examples define objects and their properties. In the first
case we define a Person object which is
identified by the string somePerson. This object has
two properties, a firstName and a
lastName. This example is probably easy to understand
because the names used are English words. However, for the TypoScript
parser the second example makes equally sense - if it makes sense at all
is only determined by the scope in which the TypoScript code is
used.
TypoScript is not only well suited for defining objects and properties but is also specialized in mapping hierarchical structures:
Example 3.3. A Person and some more properties
somePerson = Person somePerson.firstName = "John" somePerson.lastName = "Doe" somePerson.address.street = "Rigensgade" somePerson.address.city = "København"
Some people argue that other well-established formats exist which could be used instead of TypoScript. But although we, as the TYPO3 developers, are very open towards using standards, we are still convinced that TypoScript is the best syntax for the job. It is safer to write than YAML, way less typing than XML, doesn't require the amount of knowledge you'd need for PHP and it can be learned in a few minutes. You'll see in the next sections that TypoScript is much easier to learn than you might expect from its reputation.