TypoScript setup

In step Minimal site package - The TYPO3 Fluid version we placed all TypoScript into the site set, file packages/site-package/Configuration/Sets/SitePackage/setup.typoscript.

In the following chapters we will need additional TypoScript setup configurations.

Theoretically you could put all TypoScript into one big file and it would work fine. But you have better overview if you split it up in multiple files ordered by purpose.

Familiarize yourself with the TypoScript @import syntax first: TYPO3 Explained, @import syntax.

Import the TypoScript from a different location

Create a new folder called Configuration/TypoScript/Setup. In this create a file called pageview.typoscript and copy the content from file Configuration/Sets/SitePackage/setup.typoscript into it.

Then change the latter file to contain the following:

Configuration/Sets/SitePackage/setup.typoscript
@import 'EXT:site_package/Configuration/TypoScript/Setup/pageview.typoscript'
Copied!

Flush the caches and preview the page. The output should be unchanged.

Import all TypoScript files from a folder using a wildcard

We will create more TypoScript files in the next steps. We could import them file by file. But as the order will not matter we can import all of them via wildcard:

EXT:site_package/Configuration/Sets/SitePackage/setup.typoscript
@import 'EXT:site_package/Configuration/TypoScript/Setup/*.typoscript'
@import 'EXT:site_package/Configuration/TypoScript/Setup/Navigation/*.typoscript'
Copied!

Only files from the folder directly will be imported. If you create subfolders later on you have to import them separately.

Structure of the Configuration directory

Your Configuration directory should now have the following structure:

  • EXT:my_sitepackage/Configuration

    • Sets

      • SitePackage

        • config.yaml
        • setup.typoscript
    • TypoScript

      • Setup

        • pageview.typoscript

In the next steps you will create more TypoScript files to configure the Content mapping and the menus.