Templating · Creating templates · File structure

3.2.1 Common file structure

FluidTYPO3 File contexts, Templates

Fluid Powered TYPO3 uses the Extbase convention as default locations for template files. This means that your template files are usually located in the EXT:myextensionkey/Resources/Private folder - the default folder for so-called private resources, which templates are - under three subfolders:

  1. Templates which contains your different types of templates which are again placed in subfolders, for example Templates/Content and Templates/Page.
  2. Partials which is a folder for your partial templates (for example, pieces of HTML shared by many templates). You may not need this folder - but as soon as you use f:render with the partial argument, Fluid tries to find the right partial in this location.
  3. Layouts which normally contains one layout per template type, for example Content.html, Page.html etc.

By convention, the TypoScript which configures these templates should be placed as so-called "static TypoScript setup" files in EXT:myextensionkey/Configuration/TypoScript and included or registered for inclusion using any of the methods made possible by TYPO3. You can learn more about these possibilities in 3.1.5 configuration files in provider extensions.

The three paths must be configured for the extension which you use to contain your templates. You do this by adding the standard TypoScript defining a set of Fluid view paths:

plugin.tx_myextensionkey.view {
    templateRootPath = EXT:myextensionkey/Resources/Private/Templates/
    partialRootPath = EXT:myextensionkey/Resources/Private/Partials/
    layoutRootPath = EXT:myextensionkey/Resources/Private/Layouts/

This TypoScript configuration should be added to the static TypoScript of your extension - to serve as default values. Without these paths your extension's templates will not render correctly.

Layouts and Partials

Just like in any other Fluid template you can use any Layout name you choose. We on the Fluid Powered TYPO3 team suggest you use the names Default, Content, CoreContent and Page as needed. This list shows when to use which name:

  • Page when the Layout is to be used with Page templates through fluidpages. It is suggested that all page templates share a common Layout file, but sometimes you need to add other Layouts, in which case names like FrontPage and SubPage and so on, will make a lot of sense to use.
  • Content when the Layout is for fluidcontent elements - normally, you only need one Layout for content elements but like Page templates, you can split content element layouts into fx MediaContent, TextContent etc. Layout files.
  • CoreContent when the Layout is for fluidcontent_core elements. You should not ever diverge from this convention for this particular extension - consistency and with it predicactability is very important for core content templates.
  • Default when for example all your Layout file contains is an <f:render /> statement rendering one section. If your Layout HTML is this simple, sharing a Layout file gives you a small performance boost and increases transparency - compiling one file is naturally faster than multiple files, and having one file leaves zero doubt about which Layout gets used by which template.

Other than these naming conventions there are no particular rules or recommendations for Layouts set by Fluid Powered TYPO3. It is completely up to you as developer/designer to decide what, if anything, your Layouts should contain.

Partials are completely free to be used whenever you want, for whatever you want. They can contain shared Previews, common Flux form fields, Grid definitions etc. - you simply have to place an f:render statement in the right place to "include" those.

Jump to...