Attention

TYPO3 v10 has reached end-of-life as of April 30th 2023 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.

Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.

FLUIDTEMPLATE

An object of type FLUIDTEMPLATE combines TypoScript with the Fluid templating engine. It has replaced the older and now deprecated TEMPLATE content object.

FLUIDTEMPLATE generates content using Fluid templates. It can be used in content elements or to generate content within the top-level object page (see the example on this page).

Data available in Fluid templates

The following data will be available in the called Fluid template:

  • The content of the current data array.

    • On page level it contains the current page record.

    • If the FLUIDTEMPLATE is used in the context of the Fluid ViewHelper <f:cObject> it contains the data set in the Fluid Property data.

    • If called in the context of Extbase it contains the data assigned to the view in the Controller.

  • The settings array set by the parameter settings

  • Variables set by the setting variables

  • Additional data retrieved by data processors

You can use the ViewHelper debug to receive a complete listing of the available data using the magic {_all} variable:

<f:debug>{_all}</f:debug>

Properties

dataProcessing

dataProcessing

| Data type: array of class references by full namespace |

Add one or multiple processors to manipulate the $data variable of the currently rendered content object, like tt_content or page. The sub- property options can be used to pass parameters to the processor class.

Note

The content was moved to the subpage dataProcessing.

extbase.controllerActionName

extbase.controllerActionName

| Data type: string /stdWrap |

Sets the name of the action.

extbase.controllerExtensionName

extbase.controllerExtensionName

| Data type: string /stdWrap |

Sets the extension name of the controller.

Important: This is for example essential if you have translations at the usual paths in your extension and want to use them right away in your template via <f:translate/>.

extbase.controllerName

extbase.controllerName

| Data type: string /stdWrap |

Sets the name of the controller.

extbase.pluginName

extbase.pluginName

| Data type: string /stdWrap |

Sets variables for initializing extbase.

file

file

| Data type: string /stdWrap |

The fluid template file. It is an alternative to ".template" and is used only, if ".template" is not set.

Example:

page = PAGE
page {
   10 = FLUIDTEMPLATE
   10 {
      file = EXT:site_package/Resources/Private/Templates/Page/MyTemplate.html
   }
}

format

format

| Data type: keyword /stdWrap | Default: html |

format sets the format of the current request. It can be something like "html", "xml", "png", "json". And it can even come in the form of "rss.xml" or alike.

layoutRootPath

layoutRootPath

| Data type: file path /stdWrap |

Sets a specific layout path, usually EXT:some_extension/Resources/Private/Layouts/ or a folder below that path.

Note

It is recommended to use layoutRootPaths (mind the plural "s") as it can be easily extended by custom templates provided by the sitepackage.

layoutRootPaths

layoutRootPaths

| Data type: array of file paths with stdWrap |

Note

Mind the plural -s in "layoutRootPaths"!

Used to define several paths for layouts, which will be tried in reversed order (the paths are searched from bottom to top). The first folder where the desired layout is found, is used. If the array keys are numeric, they are first sorted and then tried in reversed order.

Example:

page {
   10 = FLUIDTEMPLATE
   10 {
      file = EXT:site_default/Resources/Private/Templates/Main.html
      layoutRootPaths {
         10 = EXT:site_default/Resources/Private/Layouts
         20 = EXT:site_modification/Resources/Private/Layouts
      }
   }
}

If property layoutRootPath (singular) is also used, it will be placed as the first option in the list of fall back paths.

partialRootPath

partialRootPath

| Data type: file path /stdWrap |

Sets a specific partial path, usually EXT:some_extension/Resources/Private/Partials/ or a folder below that path.

Note

It is recommended to use partialRootPaths (mind the plural "s") as it can be easily extended by custom templates provided by the sitepackage.

partialRootPaths

partialRootPaths

| Data type: array of file paths with stdWrap |

Note

Mind the plural -s in "partialRootPaths"!

Used to define several paths for partials, which will be tried in reversed order. The first folder where the desired partial is found, is used. The keys of the array define the order.

See layoutRootPaths for more details.

settings

settings

| Data type: array of keys |

Sets the given settings array in the fluid template. In the view, the value can then be used.

Example:

page = PAGE
page {
   10 = FLUIDTEMPLATE
   10 {
      file = EXT:site_default/Resources/Private/Templates/MyTemplate.html
      settings {
         copyrightYear = 2013
      }
   }
}

To access copyrightYear in the template file use this:

{settings.copyrightYear}

Apart from just setting a key-value pair as done in the example, you can also reference objects or access constants as well.

stdWrap

stdWrap

| Data type: ->stdWrap |

Offers the usual stdWrap functionality.

template

template

| Data type: cObject |

Use this property to define a content object, which should be used as template file. It is an alternative to ".file"; if ".template" is set, it takes precedence.

This property can be used to create the Fluid template dynamically from a TypoScript object.

Example:

page.10 = FLUIDTEMPLATE
page.10 {
  template = TEXT
  template.value (
    <f:debug>{_all}</f:debug>
    <h1>{data.title}</h1>
    <p>{foo}</p>
   )
  variables {
      foo = TEXT
      foo.value = bar
   }
}

Deprecated since version 9.5: Before TYPO3 9 the template property was sometimes used with the deprecated content element type cobj-file. Migrate them as follows:

page.10 = FLUIDTEMPLATE
page.10 {
   // FILE is deprecated, don't use it anymore
   // template = FILE
   // template.file = fileadmin/Templates/MyTemplate.html
   file = fileadmin/Templates/MyTemplate.html
}

or:

page.10 = FLUIDTEMPLATE
page.10 {
   templateRootPaths.200 = fileadmin/Templates/
   templateName = MyTemplate
}

templateName

templateName

| Data type: string /stdWrap |

This name is used together with the set format to find the template in the given templateRootPaths. Use this property to define a content object, which should be used as template file. It is an alternative to .file. If .templateName is set, it takes precedence.

Example 1:

lib.stdContent = FLUIDTEMPLATE
lib.stdContent {
   templateName = Default
   layoutRootPaths {
      10 = EXT:frontend/Resources/Private/Layouts
      20 = EXT:sitemodification/Resources/Private/Layouts
   }
   partialRootPaths {
      10 = EXT:frontend/Resources/Private/Partials
      20 = EXT:sitemodification/Resources/Private/Partials
   }
   templateRootPaths {
      10 = EXT:frontend/Resources/Private/Templates
      20 = EXT:sitemodification/Resources/Private/Templates
   }
   variables {
      foo = TEXT
      foo.value = bar
   }
}

Example 2:

lib.stdContent = FLUIDTEMPLATE
lib.stdContent {
   templateName = TEXT
   templateName.stdWrap {
      cObject = TEXT
      cObject {
         data = levelfield:-2,backend_layout_next_level,slide
         override.field = backend_layout
         split {
            token = frontend__
            1.current = 1
            1.wrap = |
         }
      }
      ifEmpty = Default
   }
   layoutRootPaths {
      10 = EXT:frontend/Resources/Private/Layouts
      20 = EXT:sitemodification/Resources/Private/Layouts
   }
   partialRootPaths {
      10 = EXT:frontend/Resources/Private/Partials
      20 = EXT:sitemodification/Resources/Private/Partials
   }
   templateRootPaths {
      10 = EXT:frontend/Resources/Private/Templates
      20 = EXT:sitemodification/Resources/Private/Templates
   }
   variables {
      foo = bar
   }
}

templateRootPath

templateRootPath

| Data type: file path /stdWrap |

Sets a specific template path, usually EXT:some_extension/Resources/Private/Templates/ or a folder below that path.

Note

It is recommended to use templateRootPaths (mind the plural "s") as it can be easily extended by custom templates provided by the sitepackage.

templateRootPaths

templateRootPaths

| Data type: array of file paths with stdWrap |

Note

Mind the plural -s in "templateRootPaths"!

Used to define several paths for templates, which will be tried in reversed order (the paths are searched from bottom to top). The first folder where the desired layout is found, is used. If the array keys are numeric, they are first sorted and then tried in reversed order.

Useful in combination with the templateName property.

Example:

page {
   10 = FLUIDTEMPLATE
   10 {
      templateName = Default
      templateRootPaths {
         10 = EXT:sitedesign/Resources/Private/Templates
         20 = EXT:sitemodification/Resources/Private/Templates
      }
   }
}

variables

variables

| Data type: (array of cObjects) |

Sets variables that should be available in the fluid template. The keys are the variable names in Fluid.

Reserved variables are "data" and "current", which are filled automatically with the current data set.

Example

The Fluid template in EXT:site_default/Resources/Private/Templates/MyTemplate.html could look like this:

<h1>{data.title}<f:if condition="{data.subtitle}">, {data.subtitle}</f:if></h1>
<h3>{mylabel}</h3>
<f:format.html>{data.bodytext}</f:format.html>
<p>&copy; {settings.copyrightYear}</p>

You could use it with a TypoScript code like this:

page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
   templateName = MyTemplate
   templateRootPaths {
      10 = EXT:site_default/Resources/Private/Templates
   }
   partialRootPaths {
      10 = EXT:site_default/Resources/Private/Partials
   }
   variables {
      mylabel = TEXT
      mylabel.value = Label coming from TypoScript!
   }
   settings {
      # Get the copyright year from a TypoScript constant.
      copyrightYear = {$year}
   }
}

As a result the page title and the label from TypoScript will be inserted as headlines. The copyright year will be taken from the TypoScript constant "year".