How to include all Static Templates with your TYPO3 sitepackage
What are Static Templates in TYPO3?
Static templates are TypoScript files that contain specific configurations. They are used, for example, to extend the appearance or behavior of an extension in TYPO3. To integrate these configurations into TYPO3, they have to be included via a template.
In practice, the whole thing usually looks something like this:
Why do we include Static Templates via the sitepackage and not via the template record in TYPO3?
We at MFC work with the versioning system Git. Often enough, multiple employees will work on the same project but in different branches.
If one of the employees were to add an extension with a Static Template, every other employee would also have to adapt the static templates in their local development environment, when switching to the same branch. The same issue would also occur if the branch is deployed to a testing or staging system and another branch was previously deployed there.
Ergo: Unnecessary, multiple effort, as well as increased documentation requirements.
How do we include all Static Templates with the sitepackage?
Update 01/2023: in the original blog post, we had loaded the includes in two separate TypoScript files. The new examples show our current way of working. We also removed the old include syntax of TYPO3 v8 from this tutorial.
The two files constants.typoscript
and setup.typoscript
are provided by the addStaticFile()
method in our Sitepackage. Please refer to the official TYPO3 documentation for more details.
Depending on the project, the directory structure will look something like this:
constants.typoscript
######################
#### DEPENDENCIES ####
######################
@import 'EXT:bootstrap_package/Configuration/TypoScript/constants.typoscript'
@import 'EXT:blog/Configuration/TypoScript/Integration/constants.typoscript'
@import 'EXT:picturecredits/Configuration/TypoScript/constants.typoscript'
@import 'EXT:sg_cookie_optin/Configuration/TypoScript/Frontend/constants.typoscript'
@import 'EXT:bw_captcha/Configuration/TypoScript/constants.typoscript'
@import 'EXT:solr/Configuration/TypoScript/Solr/constants.typoscript'
########################
#### PROJECT CONFIG ####
########################
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/Constants/*.typoscript'
setup.typoscript
######################
#### DEPENDENCIES ####
######################
@import 'EXT:bootstrap_package/Configuration/TypoScript/setup.typoscript'
@import 'EXT:blog/Configuration/TypoScript/Integration/setup.typoscript'
@import "EXT:typo3_encore/Configuration/TypoScript/setup.typoscript"
@import 'EXT:picturecredits/Configuration/TypoScript/setup.typoscript'
@import 'EXT:form_element_linked_checkbox/Configuration/TypoScript/setup.typoscript'
@import 'EXT:sg_cookie_optin/Configuration/TypoScript/Frontend/setup.typoscript'
@import 'EXT:bw_captcha/Configuration/TypoScript/setup.typoscript'
@import 'EXT:solr/Configuration/TypoScript/Solr/setup.typoscript'
@import 'EXT:yoast_seo/Configuration/TypoScript/setup.typoscript'
########################
#### PROJECT CONFIG ####
########################
// Elements
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/Elements/01_Configuration.typoscript'
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/Elements/02_Plugin.typoscript'
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/Elements/10_PageTemplate.typoscript'
// Content Elements
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/ContentElements/Helper/*.typoscript'
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/ContentElements/*.typoscript'
// Extensions
@import 'EXT:mfc_sitepackage/Configuration/TypoScript/Extensions/*.typoscript'
Both in the TypoScript constants and the setup, we first include all extensions that are required in the project. These can be third-party extensions, but also project-specific custom developments.
Only then do we include the other, individual configurations from the sitepackage:
- overwriting TS constants from third-party extensions
- project-specific basic configurations
- configuration of custom (content) elements
- modification or addition of extension configurations
- the
PAGE
setup (or overrides of an existingPAGE
object, if you use solutions like the Bootstrap Package)
Please feel free to share this article.
Comments
No comments yet.