Login / Status
developer.Resource
Home . Documentation . Document Library . Core Documentation
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

2.7. Technical implementation in PHP

The technical implementation of the templates in PHP is so when the required templates are found, the setup and constants-field are textually concatenated and divided by a [GLOBAL]-tag in order to ensure resetting to the global scope between each template.

Afterwards the data from the constant-field is parsed. Thus all constants are known. Now a string-replace operation is performed in the setup-data in order to substitute constants. Now the setup-data is parsed.

Parsing TypoScript means that a script is converted into a PHP-array that reflects the structure of TypoScript. This can best be shown by an example:

TypoScript:
pageObj.20 = HTML
pageObj.20 {
  value = Hello Netscape or Windows NT users!!
  value.case = upper
}
PHP Array:
$setup["pageObj."]["20"] = "HTML";
$setup["pageObj."]["20."]["value"] = "Hello Netscape or Windows NT users!!";
$setup["pageObj."]["20."]["value."]["case"] = "upper";

Template cache

When a TypoScript is parsed and loaded into an array, then information about 1) all the conditions there has been in TypoScript and 2) all of these conditions that were met is collected. This information together with data about other things is converted to an md5-hash which are the unique identification of this template.

The template is serialized and saved in a cache-table in SQL.

The next time this template is requested - the conditions taken into account - then you get template as an array from the template cache-table. Thereby the template does not need the be parsed once again.

The Rootline

"Rootline" is a term used for the line of pages from somewhere in the treestructure to the root of the website. On this illustration you can see it quite clearly. To the left is a "print" of the rootline, when the page "Experience..." was hit. It was printed with this line of code from "pagegen.php".

debug($GLOBALS["TSFE"]->tmpl->rootLine);

With PHP you can reach the title of the page on the second level by this reference:

$GLOBALS["TSFE"]->tmpl->rootLine[1]["title"]

With TypoScript you can do it by the stdWrap-function  (".data"-property and "getText"-datatype)

.data = leveltitle : 1

IMPORTANT: Please notice, that the rootLine will always start over from zero when the "Rootlevel" checkbox is set in a template!

Two kinds of rootline:

In the array $GLOBALS["TSFE"]->rootLine you have the rootline all the way to the pagetree root (that is PID=0). In the array $GLOBALS["TSFE"]->config["rootLine"] you have only the rootline of the current site (which is what was described above). $GLOBALS["TSFE"]->config["rootLine"] is the same as $GLOBALS["TSFE"]->tmpl->rootLine.

Currently the rootline array holds the uid, title, media and layout field of the page-records represented in the rootline array (the image above displays only title and uid)