Render.record ViewHelper <f:render.record>
New in version 14.2
Instead of using the
<f: ViewHelper to render database records,
use the new
<f: ViewHelper.
This ViewHelper renders a record object via its TypoScript definition. The most common use case is rendering a content element that is available as a record object in a Fluid template.
By default, the ViewHelper renders the record as-is. However, event listeners
can listen to the
\TYPO3\
to modify the output.
Go to the source code of this ViewHelper: Render\RecordViewHelper.php (GitHub).
Table of contents
Rendering content elements using the record-transformation data processor
<f:render.record record="{record}"/>
Or using inline syntax:
{record -> f:render.record()}
dataProcessing {
10 = record-transformation
}
Rendering arbitrary database records
You can render any database record that has valid TCA, including categories and records provided by third-party extensions.
Rendering system categories
You can render not only tt_ records but any database record by defining
a top-level TypoScript object with the name of the record table.
For example, to render system categories, use sys_
(FLUIDTEMPLATE)
to configure the rendering.
sys_category = FLUIDTEMPLATE
sys_category {
file = EXT:my_sitepackage/Resources/Private/Templates/Category/Default.html
layoutRootPaths.10 = EXT:my_sitepackage/Resources/Private/Layouts/Category/
partialRootPaths.10 = EXT:my_extension/Resources/Private/Partials/Category/
dataProcessing.1774685451 = record-transformation
}
<f:for each="{categories}" as="category">
{category -> f:render.record()}
</f:for>
page = PAGE
page {
10 = PAGEVIEW
10 {
paths.10 = EXT:my_sitepackage/Resources/Private/Templates/
dataProcessing {
10 = database-query
10 {
as = categories
table = sys_category
where = parent=0
dataProcessing.1774685450 = record-transformation
}
}
}
}
Rendering records with types
If you want to render a database record that has different types, you can use a TypoScript Content object array (COA) to configure rendering for special types:
tx_myextension_domain_model_product = COA
tx_myextension_domain_model_product {
key {
field = my_type
}
default = FLUIDTEMPLATE
default {
templateName >
templateName.ifEmpty.cObject = TEXT
templateName.ifEmpty.cObject {
field = record_type
required = 1
case = uppercamelcase
}
# for record_type = 'mainProduct' the template file my_extension/Resources/Private/Templates/Product/MainProduct.html will be used
templateRootPaths.10 = EXT:my_extension/Resources/Private/Templates/Product/
layoutRootPaths.10 = EXT:my_extension/Resources/Private/Layouts/
partialRootPaths.10 = EXT:my_extension/Resources/Private/Partials/
dataProcessing.1421884800 = record-transformation
}
mySpecialType.templateRootPaths.20 = EXT:my_extension/Resources/Private/Templates/ProductSpecial/
}
Intercepting the rendering of records via events
With the
\TYPO3\, developers can
intercept the rendering of individual records in Fluid templates to modify the
output.
Arguments of the <f:render.record> ViewHelper
record
-
- Type
- TYPO3\CMS\Core\Domain\RecordInterface
The record to be rendered