We have already pointed out that TypoScript is programmed in PHP. However, you do not have to know PHP syntax to be able to work with TypoScript; but knowledge of PHP is definitely an advantage. You can, for example, easily import information from the PHP class files using appropriate objects and values. The following example will show how this works.
Anyone who wants to know more about the structure and the development (from a programming point of view) of TypoScript should take a look at the tslib
directory. It contains the PHP classes that control TypoScript.
For a better understanding open the file typo3/sysext/cms/tslib/class.tslib_content.php
. You will find numerous PHP functions in it. We will concentrate on the CTABLE()
function.
Thanks to this function, elements can easily be positioned with the help of a table. What does this mean for TypoScript? To understand this take a look at the following syntax, which uses the Content Object (cObject) CTABLE:
Using page.10.marks.TABLE
, a new TypoScript object of the CTABLE
type is defined. Using TypoScript, the remaining lines define the look and the content of the table. You are surely familiar with the HTML layout attributes; TypoScript's own attributes such as HMENU
etc. will be shown later. Note that you will need templates and placeholders to get this example to work. More information on these can be found in Chapter 4 and Chapter 5. The output of this example is shown below:
If you want to work more closely with the PHP functions, take one function after another and experiment with it. You will gradually understand how the meshing between TypoScript and PHP works. At the same time you also have an opportunity to learn about the weaknesses of TypoScript. Each TypoScript object can only deliver what the programmer has designed into the respective function (except when you develop your own functions).
The core of TypoScript is the typo3/sysext/cms/tslib/index_ts.php
file. It charts the information about the template datasets of the website tree. How this works is shown by the following TypoScript:
This syntax creates the TypoScript object mybicycle
. You assign the properties color
and size
to the mybicycle
object. These two properties in turn are assigned the following values: color
becomes blue
and size
gets the value 26
. In the TypoScript Object Browser you will see objects, properties, and values represented as follows:
PHP can also be used directly in TYPO3; we will cover more about this later.