FLUIDTEMPLATE

An object of type FLUIDTEMPLATE combines TypoScript with the Fluid templating engine.

Changed in version 11.0

The content object FLUIDTEMPLATE has replaced TEMPLATE which was removed with version 11.0.

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

Data available in Fluid templates

The following data is available in the Fluid template:

  • The content of the current data array.

    • At page level it contains the current page record.
    • If the FLUIDTEMPLATE is used in the context of the Fluid ViewHelper CObject ViewHelper <f:cObject> it contains data 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 in the variables setting
  • Data retrieved by data processors

You can use the debug ViewHelper to output all available data using the magic {_all} variable:

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

Properties

cache

cache
Type
cache

See cache function description for details.

dataProcessing

dataProcessing
Type
array of class references by full namespace

Add one or more processors to manipulate the $data variable of the currently rendered content object, such as tt_content or page. Use the sub-property options to pass parameters to the processor class.

extbase.controllerActionName

extbase.controllerActionName
Type
string / stdWrap

Sets the name of the action.

extbase.controllerExtensionName

extbase.controllerExtensionName
Type
string / stdWrap

Sets the extension name of the controller.

extbase.controllerName

extbase.controllerName
Type
string / stdWrap

Sets the name of the controller.

extbase.pluginName

extbase.pluginName
Type
string / stdWrap

Sets variables for initializing extbase.

file

file
Type
string / stdWrap

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

Example
EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:my_sitepackage/Resources/Private/Templates/Page/MyTemplate.html
    }
}
Copied!

format

format
Type
keyword / stdWrap
Default
html

format sets the format of the current request. It can be something like "html", "xml", "png", "json" or even "rss.xml" or something similar.

layoutRootPath

layoutRootPath
Type
path / stdWrap

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

layoutRootPaths

layoutRootPaths
Type
array of path with stdWrap

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
EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:my_sitepackage/Resources/Private/Templates/Main.html
        layoutRootPaths {
            10 = EXT:my_base_sitepackage/Resources/Private/Layouts
            20 = EXT:my_sitepackage/Resources/Private/Layouts
        }
    }
}
Copied!

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

partialRootPath

partialRootPath
Type
path / stdWrap

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

partialRootPaths

partialRootPaths
Type
array of path with stdWrap

Used to define several paths for partials, which will be tried in reverse 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
Type
array of keys

Sets the settings array in the fluid template. The value can then be used in the view.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:site_default/Resources/Private/Templates/MyTemplate.html
        settings {
            copyrightYear = 2013
        }
    }
}
Copied!

To access copyrightYear in the template file use:

{settings.copyrightYear}
Copied!

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

stdWrap

stdWrap
Type
->stdWrap

Provides the usual stdWrap functionality.

template

template
Type
cObject

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

templateName

templateName
Type
string / stdWrap

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

Example 1
EXT:site_package/Configuration/TypoScript/setup.typoscript
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
    }
}
Copied!
Example 2
EXT:site_package/Configuration/TypoScript/setup.typoscript
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
    }
}
Copied!

templateRootPath

templateRootPath
Type
file path /stdWrap

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

templateRootPaths

templateRootPaths
Type
array of file paths with stdWrap

Used to define several paths for templates, which will be tried in reverse 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 reverse order.

Useful in combination with the templateName property.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page {
    10 = FLUIDTEMPLATE
    10 {
        templateName = Default
        templateRootPaths {
            10 = EXT:sitedesign/Resources/Private/Templates
            20 = EXT:sitemodification/Resources/Private/Templates
        }
    }
}
Copied!

variables

variables
Type
(array of cObjects)

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

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

Example

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

EXT:my_sitepackage/Resources/Private/Templates/MyTemplate.html
<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>
Copied!

You could use it with TypoScript code like this:

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

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