Using Inheritance in TypoScript Templates

Motivation

The idea came from when an interested party asked us to take a look at his TYPO3 system. He criticized the length of time needed by his programmer for structural changes.

Negative Example

Having taken a look at the TypoScript templates it was quickly evident what was causing these lengthy processing times: The programmer (a TYPO3 newbie) had integrated the root template into the homepage and then copied it to all sub-pages. In principal this works, but as soon as changes need to be made to the TypoScript code then these need to be made to every copied template.

Best Practice

The main part of the TypoScript programming should be included in the so-called root template of the website's homepage.

A root template can be created by adding a new template record to the homepage. This is done by selecting "Create template for a new site" as opposed to "Click here to create an extension template" which are used on sub-pages.

There are two options for saving TypoScript code:

1. All commands are saved in a single root template. Depending on the complexity of the website this template can be very extensive.

2. (Our recommendation) The commands are distributed across several templates which are then integrated into the original root template. Distribution can be made for example in accordance with the website parts (navigation, header, footer, content etc).

The code of a TypoScript template is inherited by all sub-pages. It is therefore not necessary to copy the entire template to sub-sites.

If certain commands from the root template cannot be implemented to a sub-page or need to be implemented differently, then it suffices to simply adapt the required code. It is also possible to integrate the required extension template code (via "Extension Templates") only onto the pages on which the relevant extension features.

When it comes to extension templates it is important that no ticks are added to the "Constants" and "Setup" checkboxes (displayed below "Delete" in the "Options" tab), because otherwise all inherited TypoScript commands will be ignored.

Visitors found this page by searching for these keywords:

typo3 template inheritance · typo3 inherit template · typo3 inheritance · checkbox checked using extbase with fluid template · extbase typoscripttemplates