Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 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 v11 here: TYPO3 ELTS.
CObject ViewHelper <f:cObject>
This ViewHelper renders CObjects from the global TypoScript configuration.
Note
You have to ensure proper escaping (htmlspecialchars/intval/etc.) on your own!
Examples
Render lib object
<f:cObject typoscriptObjectPath="lib.someLibObject" />
Rendered lib.
.
Specify cObject data & current value
<f:cObject typoscriptObjectPath="lib.customHeader" data="{article}" currentValueKey="title" />
Rendered lib.
. Data and current value will be available in TypoScript.
Inline notation
{article -> f:cObject(typoscriptObjectPath: 'lib.customHeader')}
Rendered lib.
. Data will be available in TypoScript.
Accessing the data in TypoScript
lib.customHeader = COA
lib.customHeader {
10 = TEXT
10.field = author
20 = TEXT
20.current = 1
}
When passing an object with {data}
, the properties of the object are accessible with .field
in
TypoScript. If only a single value is passed or the currentValueKey
is specified, .current = 1
can be used in the TypoScript.
Source code
Go to the source code of this ViewHelper: CObjectViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
data
-
- Type
- mixed
The data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used
typoscriptObjectPath
-
- Type
- string
- Required
true
The TypoScript setup path of the TypoScript object to render
currentValueKey
-
- Type
- string
CurrentValueKey
table
-
- Type
- string
The table name associated with "data" argument. Typically tt_content or one of your custom tables. This argument should be set if rendering a FILES cObject where file references are used, or if the data argument is a database record.