stdWrap
A "stdWrap" TypoScript property ("standard wrap") is a function that "wraps" text values. A TEXT object value is parsed by the stdWrap function using the value's properties as parameters.
Table of contents
Content-supplying properties of stdWrap
The properties that can be supplied as parameters are listed below.
Note
Content-supplying properties are those that import content
from other variables or arrays. These properties are parsed in the order
data
,
field
,
current
,
c
.
For further information see
EXT:frontend/Classes/ContentObject/ContentObjectRenderer.php (GitHub)
on the
std
function and on the array
$std
,
which represents the order of execution.
Use the
std
property "orderedStdWrap" if you want to execute
multiple
std
functions in an order you choose.
In the example below, the line
10.
is discarded
because the value is imported from the header field in
$c
.
10 = TEXT
10.value = some text
10.stdWrap.case = upper
10.stdWrap.field = header
Properties
Properties for getting data
Name | Type |
---|---|
boolean / stdWrap | |
string / stdWrap | |
string / stdWrap | |
Array of language keys / stdWrap | |
Data / getText / stdWrap | |
Field name / stdWrap | |
boolean / stdWrap | |
Content Objects (cObject) | |
->numRows / stdWrap | |
function name |
setContentToCurrent
addPageCacheTags
-
Comma-separated list of cache tags to tag pages in the page cache.
ExamplesaddPageCacheTags = pagetag1,pagetag2,pagetag3
Copied!This will add the tags "pagetag1", "pagetag2" and "pagetag3" to the cached pages in cache_pages.
Cached pages with a tag can be deleted from the cache using the TSconfig option TCEMAIN.clearCacheCmd.
setCurrent
lang
-
- Type
- Array of language keys / stdWrap
This is used to define optional language specific values based on the current site language.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = TEXT page.10.value = I am a Berliner! page.10.stdWrap.lang.de = Ich bin ein Berliner!
Copied!Output will be "Ich bin..." instead of "I am..."
data
-
- Type
- Data / getText / stdWrap
field
-
- Type
- Field name / stdWrap
Sets the content to the value of the corresponding field (from
$c
).Obj->data [*field*] Note
$c
changes depending on the context. See the description of the data type "Data / getText" fieldObj->data ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10.field = title
Copied!This sets the content to the value of the field "title".
You can provide multiple field name options separated by "//".
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10.field = nav_title // title
Copied!The content from the
nav_
field will be returned unless it is a blank string. If it is a blank string, the value of the title field is returned.title
current
cObject
-
Loads content from a content object.
numRows
preUserFunc
-
- Type
- function name
Calls a provided PHP function. If you specify the name with a '->' in it, then it is interpreted as a call to a class method.
Two parameters are sent to the PHP function: a content variable, which contains the current content (the value to be processed), and any sub-properties of preUserFunc.
Properties for overriding and conditions
Name | Type |
---|---|
string / stdWrap | |
(as "" below) | |
string / stdWrap | |
string / stdWrap | |
string / stdWrap | |
string / stdWrap | |
string | |
boolean / stdWrap | |
strPad | |
stdWrap | |
boolean / stdWrap | |
if | |
Field name / stdWrap |
override
preIfEmptyListNum
ifNull
-
Sets the content if the content is null (
NULL
type in PHP).ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = COA_INT page.10 { 10 = TEXT 10 { stdWrap.field = description stdWrap.ifNull = No description defined. } }
Copied!This example displays the content of the description field or, if that value is
NULL
, the text "No description defined.".
ifEmpty
ifBlank
listNum
-
Explodes the current content (Default:
,
) and returns the object specified bylist
.Num Possible values:
last
- The special keyword
last
is replaced with the index of the last element in the exploded content. rand
- The special keyword
rand
is replaced with the index of a random element in the exploded content. - Calc
- After the special keywords are replaced with their numeric values.
- 0 - last
- If the content of
list
can be interpreted as an integer the corresponding index of the exploded content is returned. Counting starts at 0.Num
ExamplesThis would return "item 1":
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = TEXT page.10.value = item 1, item 2, item 3, item 4 page.10.listNum = 0
Copied!This would return "item 3"
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = TEXT page.10.value = item 1, item 2, item 3, item 4 page.10.listNum = last – 1
Copied!listNum.splitChar
-
- Type
- string
- Default
,
(comma)
ExamplesSplits the content of the
subtitle
field by the pipe character and returns a random elementEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.5 = COA_INT page.5 { 10 = TEXT 10 { stdWrap.field = subtitle stdWrap.listNum = rand stdWrap.listNum.splitChar = | } }
Copied!
trim
strPad
-
- Type
- strPad
Pads the current content to a certain length. You can define the padding characters and which side(s) the padding should be added.
stdWrap
-
- Type
- stdWrap
Recursive call to the
std
function.Wrap
required
if
-
- Type
- if
If the if-object returns false, stdWrap returns "".
fieldRequired
-
- Type
- Field name / stdWrap
The value in this field must be set.
Properties for parsing data
Name | Type |
---|---|
string / stdWrap | |
object path reference / parseFunc / stdWrap | |
boolean / HTMLparser / stdWrap | |
split / stdWrap | |
replacement / stdWrap | |
boolean / stdWrap | |
integer / stdWrap | |
boolean / stdWrap | |
string / stdWrap | |
round / stdWrap | |
numberFormat | |
date-conf / stdWrap | |
string | |
/ stdWrap | |
string | |
boolean or string / stdWrap | |
string / stdWrap | |
boolean / stdWrap | |
[p1], [p2] / stdWrap | |
string / stdWrap | |
boolean / stdWrap | |
string / stdWrap | |
boolean / stdWrap | |
boolean / stdWrap | |
boolean / stdWrap | |
string / stdWrap | |
boolean / stdWrap | |
string / stdWrap | |
encapsLines / stdWrap | |
boolean / stdWrap |
csConv
parseFunc
-
Processing instructions to be applied to content.
Note
If you enter a string value, this will be interpreted as a reference to a global object path in the TypoScript object tree. This will be the basic configuration for parseFunc merged with any properties you add here. It works like references does for content elements.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 { parseFunc = < lib.parseFunc_RTE parseFunc.tags.myTag = TEXT parseFunc.tags.myTag.value = This will be inserted when <myTag> is found! }
Copied!
html
is enabled by default when
parse
is invoked. This includes the Fluid Viewhelper
<f:
, since it invokes
parse
directly using
lib.
.
The following example shows how to disable the sanitization behavior (enabled by default). This is not recommended.
// either disable globally
lib.parseFunc.htmlSanitize = 0
lib.parseFunc_RTE.htmlSanitize = 0
// or disable individually per use case
10 = TEXT
10 {
value = <div><img src="invalid.file" onerror="alert(1)"></div>
parseFunc =< lib.parseFunc_RTE
parseFunc.htmlSanitize = 0
}
Since an invocation of
std
triggers HTML
sanitization, the following example causes a lot of generated markup to be
sanitized and can be solved by explicitly disabling it with
html
.
10 = FLUIDTEMPLATE
10 {
templateRootPaths {
// ...
}
variables {
// ...
}
stdWrap.parseFunc {
// replace --- with soft-hyphen
short.--- = ­
// sanitization of ALL MARKUP is NOT DESIRED here
htmlSanitize = 0
}
}
HTMLparser
-
- Type
- boolean / HTMLparser / stdWrap
This object allows you to parse HTML content and perform advanced filtering on the content.
Value must be set and properties are those of HTMLparser.
(See Rich text editors (RTE) for more information about RTE transformations)
split
replacement
-
- Type
- replacement / stdWrap
Performs an ordered search/replace on the current content and PCRE regular expressions can be used. An array with numeric indices defines the order of actions and thus allows multiple replacements at once.
prioriCalc
-
Calculation of the value using operators -+*/%^ while respecting the priority of + and - operators and parenthesis levels ().
. (period) is a decimal delimiter.
Returns a double value.
If
priori
is set toCalc intval
, an integer is returned.There is no error checking, and division by zero or other invalid values may generate strange results. You should use proper syntax because future modifications to the function may add more operators and features.
ExamplesExample Output for different calculations100%7 = 2 -5*-4 = 20 +6^2 = 36 6 ^(1+1) = 36 -5*-4+6^2-100%7 = 54 -5 * (-4+6) ^ 2 - 100%7 = 98 -5 * ((-4+6) ^ 2) - 100%7 = -22
Copied!
char
-
Content is set to
chr
. This returns a one-character string containing the character specified by ascii code. Reliable results will be obtained only for character codes in the integer range 0 - 127. See the PHP manual:(*value*) $content = chr((int)$conf['char']);
Copied!
intval
hash
-
Returns a hashed value of the current content. Set to one of the algorithms which are available in PHP. For a list of supported algorithms see https://www.php.net/manual/en/function.hash-algos.php.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = TEXT page.10 { value = test@example.org stdWrap.hash = md5 stdWrap.wrap = <img src="https://www.gravatar.com/avatar/|" /> }
Copied!
round
numberFormat
-
- Type
- numberFormat
Format a float value to the number format you need (e.g. useful for prices).
date
-
The content should be the an integer representing the UNIX time (second since 1.1.1970). Returns content formatted as a date. See the PHP manual (datetime.format) for format codes.
$content = date($conf['date'], $content);
Copied!Properties:
.GMT: If set, the PHP function gmdate() will be used instead of date().
ExamplesRender in human readable form:
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 = TEXT page.10.value { # format like 2017-05-31 09:08 field = tstamp date = Y-m-d H:i }
Copied!
strtotime
-
- Type
- string
Allows conversion of formatted dates to timestamps, for example to perform date calculations.
Possible values are
1
or any time string valid as the first argument of the PHPstrtotime
function.() ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptlib.date_as_timestamp = TEXT lib.date_as_timestamp { value = 2015-04-15 strtotime = 1 }
Copied!EXT:site_package/Configuration/TypoScript/setup.typoscriptlib.next_weekday = TEXT lib.next_weekday { data = GP:selected_date strtotime = + 2 weekdays strftime = %Y-%m-%d }
Copied!
strftime
-
- Type
- / stdWrap
Similar to property
date
, but uses a different format. See the PHP manual (strftime) for format codes.This formatting is useful if the locale is set in the CONFIG object.
Properties:
- .charset
- Can be set to the charset of the output string if you need to
convert it to UTF-8. The default is to take the
charset predicted by
\TYPO3\
.CMS\ Core\ Charset\ Charset Converter - .GMT
- If set, PHP function gmstrftime() will be used instead of strftime().
formattedDate
-
- Type
- string
This function renders date and time based on formats/patterns defined by the International Components for Unicode standard (ICU). ICU-based date and time formatting is much more flexible for rendering than
date
orstrftime
, as it ships with default patterns for date and time based on the given locale (the examples below are for localeen-
and timezoneUS America/
):Los_ Angeles FULL
, for example:Friday, March 17, 2023 at 3:
00: 00 AM Pacific Daylight Time LONG
, for example:March 17, 2023 at 3:
00: 00 AM PDT MEDIUM
, for example:Mar 17, 2023, 3:
00: 00 AM SHORT
, for example:3/
17/ 23, 3: 00 AM
TYPO3 also adds custom patterns:
FULLDATE
, for example:Friday, March 17, 2023
FULLTIME
, for example:3:
00: 00 AM Pacific Daylight Time LONGDATE
, for example:March 17, 2023
LONGTIME
, for example:3:
00: 00 AM PDT MEDIUMDATE
, for example:Mar 17, 2023
MEDIUMTIME
, for example:3:
00: 00 AM SHORTDATE
, for example:3/
17/ 23 SHORTTIME
, for example:3:
00 AM
Note
You can specify your own pattern to suit your requirements, for example:
qqqq, yyyy
will result in1st quarter, 2023
. Have a look into the available options.The locale is typically fetched from the locale setting in the site configuration.
Properties:
- .locale
- A locale other than the locale of the site language.
Example: Full German output from a date/time valueEXT:site_package/Configuration/TypoScript/setup.typoscriptlib.my_formatted_date = TEXT lib.my_formatted_date { value = 2023-03-17 3:00:00 formattedDate = FULL # Optional, if a different locale is wanted other than the site language's locale formattedDate.locale = de-DE }
Copied!will result in "Freitag, 17. März 2023 um 03:00:00 Nordamerikanische Westküsten-Sommerzeit".
Example: Full French output from a relative date valueEXT:site_package/Configuration/TypoScript/setup.typoscriptlib.my_formatted_date = TEXT lib.my_formatted_date { value = -5 days formattedDate = FULL formattedDate.locale = fr-FR }
Copied!will result in "dimanche 12 mars 2023 à 11:16:44 heure d’été du Pacifique".
Example: Custom format from a timestampEXT:site_package/Configuration/TypoScript/setup.typoscriptlib.my_formatted_date = TEXT lib.my_formatted_date { value = 1679022000 formattedDate = Y-MM-dd'T'HH:mm:ssZ }
Copied!will return the date in the ISO 8601 format: "2023-03-17T03:00:00+00:00"
Note
The timezone will be taken from the setting
date.
in yourtimezone php.
.ini
age
-
If enabled with a "1" (number, integer) the content is seen as a date (UNIX-time) and the difference between current time and the content-time is returned as one of these eight variations:
"xx min" or "xx hrs" or "xx days" or "xx yrs" or "xx min" or "xx hour" or "xx day" or "year"
The upper limits of the variations are 60 minutes, 24 hours and 365 days.
If you set this property as non-integer, it is used to format the eight units. The first four values are the plural values and the last four are singular. This is the default string:
Default string for age formatmin| hrs| days| yrs| min| hour| day| year
Copied!Set another string if you want to change the units. You can include "-" signs. They will be removed, but they make sure that there is a space between the number and the unit.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptlib.ageFormat = TEXT lib.ageFormat.stdWrap.data = page:tstamp lib.ageFormat.stdWrap.age = " Minuten | Stunden | Tage | Jahre | Minute | Stunde | Tag | Jahr"
Copied!
case
-
- Type
- string / stdWrap
Converts case
Uses "UTF-8" for the operation.
Possible values:Value Effect upper
Convert all letters of the string to uppercase lower
Convert all letters of the string to lowercase capitalize
Convert the first character of each word in the string to uppercase ucfirst
Convert the first letter of the string to uppercase lcfirst
Convert the first letter of the string to lowercase uppercamelcase
Convert underscored upper_
tocamel_ case Upper
Camel Case lowercamelcase
Convert underscored lower_
tocamel_ case lower
Camel Case ExampleCode:
EXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10.value = Hello world! 10.case = upper
Copied!Result:
Example OutputHELLO WORLD!
Copied!
bytes
-
This is for number values. When the 'bytes' property is added and set to 'true' then a number will be formatted in 'bytes' style with two decimals, for example, '1.53 KiB' and '1.00 MiB'. Learn about common notations in Wikipedia "Kibibyte". IEC naming with base 1024 is the default. Use subproperties for customisation.
- .labels = iec
- This is the default. IEC labels and base 1024 are used.
Built in IEC labels are
"
. You need to append a final string like 'B' or '-Bytes' yourself.| Ki | Mi | Gi | Ti | Pi | Ei | Zi | Yi" - .labels = si
- SI labels and base 1000 are used. Built in IEC labels are
"
. You need to append a final string like 'B' yourself.| k | M | G | T | P | E | Z | Y" - .labels = "..."
- Custom values can be defined such as
.labels = " Byte
. Use a vertical bar to separate the labels. Enclose the whole string in double quotes.| Kilobyte | Megabyte | Gigabyte" - .base = 1000
- You can set custom labels to base 1000. All other values, including the default, are base 1024.
Attention
If the value isn't a number the internal PHP function may issue a warning which can interrupt execution depending on you error handling settings. Example:
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 { value = abc bytes = 1 } will show `0` but may raise a warning or an exception.
Copied!ExamplesOutput value 1000 without special formatting. Shows
1000
:EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 }
Copied!Format value 1000 in IEC style with base=1024. Shows
0.
:98 Ki EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 }
Copied!Format value 1000 in IEC style with base=1024 and 'B' supplied by us. Shows
0.
:98 Ki B EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 noTrimWrap = ||B| }
Copied!Format value 1000 in SI style with base=1000. Shows
1.
:00 k EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 bytes.labels = si }
Copied!Format value 1000 in SI style with base=1000 and 'b' supplied by us. Shows
1.
:00 kb EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 bytes.labels = si noTrimWrap = ||b| }
Copied!Format value 1000 with custom label and base=1000. Shows
1.
:00 x 1000 Bytes EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 bytes.labels = " x 1 Byte| x 1000 Bytes" bytes.base = 1000 }
Copied!Format value 1000 with custom label and base=1000. Shows
1.
:00 kilobyte (k B) EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 bytes.labels = " byte (B)| kilobyte (kB)| megabyte (MB)| gigabyte (GB)| terabyte (TB)| petabyte (PB)| exabyte (EB)| zettabyte (ZB)| yottabyte YB" bytes.base = 1000 }
Copied!Format value 1000 with custom label and base=1024. Shows
0.
:98 kibibyte (Ki B) EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.10 = TEXT page.10 { value = 1000 bytes = 1 bytes.labels = " byte (B)| kibibyte (KiB)| mebibyte (MiB)| gibibyte (GiB)| tebibyte (TiB)| pepibyte (PiB)| exbibyte (EiB)| zebibyte (ZiB)| yobibyte YiB" bytes.base = 1024 }
Copied!
substring
cropHTML
-
Crops the content to a certain length. In contrast to
std
, it respects HTML tags. It does not crop inside tags and closes open tags. Entities (like ">") are counted as one char. SeeWrap. crop std
below for a syntax description and examples.Wrap. crop Note that
std
should not be used ifWrap. crop std
is already being used.Wrap. crop HTML
stripHtml
crop
-
Crops the content to a certain length.
You can define up to three parameters, where the third one is optional. The syntax is: [number of characters to keep] | [ellipsis] | [keep whole words]
numbers of characters to keep (integer): Defines the number of characters to keep. For positive numbers, the first characters from the beginning of the string will be kept, for negative numbers, the last characters from the end will be kept.
ellipsis (string): The symbols to be added replacing the part that was cropped. If the number of characters to keep is positive, the string will be prepended with the ellipsis, if it is negative, the string will be appended with the ellipsis.
keep whole words (boolean): If set to 0 (default), the string is cropped after the defined number of characters. If set to 1, complete words are kept. A word which would normally be cut in the middle will be removed.
Examples20
=> max 20 characters. If more, the value will be truncated to the first 20 characters and prepended with "..."| ... -20
=> max 20 characters. If more, the value will be truncated to the last 20 characters and appended with "..."| ... 20
=> max 20 characters. If more, the value will be truncated to the first 20 characters and prepended with "...". If the division is in the middle of a word, the rest of that word will be removed.| ... | 1 Uses "UTF-8".
rawUrlEncode
-
Passes the content through the rawurlencode() PHP function .
htmlSpecialChars
-
Passes the content through the htmlspecialchars() PHP function.
Additional property
preserve
will preserve entities so that only non-entity characters are affected.Entities
encodeForJavaScriptValue
-
Encodes content so that it can be safely used inside strings in JavaScript. Characters which can cause problems inside JavaScript strings are replaced with their encoded equivalents. The resulting string is quoted with single quotes.
Passes the content through the core function
\TYPO3\
.CMS\ Core\ Utility\ General Utility:: quote JSvalue () ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10.stdWrap { data = GP:sWord encodeForJavaScriptValue = 1 wrap = setSearchWord(|); }
Copied!
doubleBrTag
br
brTag
encapsLines
-
- Type
- encapsLines / stdWrap
Lets you split the content with
chr
and process each line independently. Used to format RTE content .(10)
keywords
Properties for wrapping data
Name | Type |
---|---|
wrap / stdWrap | |
wrap / stdWrap | |
Content Objects (cObject) | |
Content Objects (cObject) | |
string / stdWrap | |
typolink / stdWrap | |
wrap /+.splitChar / stdWrap | |
"special" wrap /+.splitChar / stdWrap | |
wrap /+.splitChar / stdWrap | |
mixed / stdWrap | |
Content Objects (cObject) | |
Content Objects (cObject) | |
wrap /+.splitChar / stdWrap | |
Array of numeric keys with / stdWrap each | |
wrap / stdWrap | |
boolean / stdWrap | |
function name | |
function name | |
string / stdWrap |
innerWrap
innerWrap2
preCObject
postCObject
wrapAlign
-
- Type
- string / stdWrap
- Allowed values
left
,center
,right
Wraps content with
<div style=text-
if align is set.align: [*value*];"> | </ div>
typolink
wrap
noTrimWrap
-
- Type
- "special" wrap /+.splitChar / stdWrap
This wraps the content without trimming the values. That means that surrounding whitespace is not removed. Note that this kind of wrap needs a special character in the middle as well as the same special character at the beginning and end of the wrap (the default for all three is "|").
Additional property:
split
Char Can be set to define an alternative special character.
std
is available. The default is "|" - the vertical line. This subproperty is useful when the default special character would be recognized by optionSplit (which takes precedence overWrap no
).Trim Wrap ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10.noTrimWrap = | val1 | val2 |
Copied!In this example the values val1 and val2 will be wrapped, including the whitespace.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10 { noTrimWrap = ^ val1 ^ val2 ^ || ^ val3 ^ val4 ^ noTrimWrap.splitChar = ^ }
Copied!optionSplit will use the "||" to determine two subparts. In each subpart
no
will then use the "^" as special character.Trim Wrap
wrap2
dataWrap
-
- Type
- mixed / stdWrap
The content is parsed for pairs of curly braces. The content of the curly braces is of the type Data / getText and is substituted with the result of Data / getText.
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptpage.10.dataWrap = <div id="{tsfe : id}"> | </div>
Copied!This will produce a
<div>
tag around the content with an id attribute that contains the id of the current page.
prepend
append
wrap3
orderedStdWrap
-
- Type
- Array of numeric keys with / stdWrap each
Execute multiple
std
statements in an order that you choose. The order is determined by the numeric order of the keys.You can use multiple stdWrap statements without having to remember the rather complex sorting order in which theWrap std
functions are executed.Wrap ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10.value = a 10.stdWrap.orderedStdWrap { 30.wrap = |. 10.wrap = is | working 10.innerWrap = | 20.wrap = This|solution 20.stdWrap.wrap = | }
Copied!In this example orderedStdWrap is executed on the value "a".
10.
is executed first, followed byinner Wrap 10.
. Then the 20 key is processed. Finallywrap 30.
is executed on what already was created.wrap This results in "This is a working solution."
outerWrap
insertData
-
If set, then the content string is parsed like
data
above.Wrap ExamplesDisplays the page title:
EXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10.value = This is the page title: {page:title} 10.stdWrap.insertData = 1 # TEXT is already stdWrapable, so we can also use insertData right away 20 = TEXT 20.value = <link rel="preload" href="{path : EXT:site/Resources/Public/Fonts/Roboto.woff2}" as="font" type="font/woff2" crossorigin="anonymous"> 20.insertData = 1
Copied!
Warning
Never use this on content that can be edited in the backend. This would
allows editors to disclose information that is normally hidden. Never
use this to insert data into wraps. Use
data
instead.
postUserFunc
-
- Type
- function name
Calls the provided PHP function. If the function name contains '->', it will be interpreted as a call to a class method.
Two parameters are sent to the PHP function: a content variable containing the current content (this is the value that will be processed) and subproperties of
post
.User Func See description of the USER
c
for more in-depth information.Object ExamplesYou can paste this example directly into a new template record:
EXT:site_package/Configuration/TypoScript/setup.typoscriptpage = PAGE page.typeNum = 0 page.10 = TEXT page.10 { value = Hello World! stdWrap.postUserFunc = MyVendor\SitePackage\UserFunctions\YourClass->reverseString stdWrap.postUserFunc.uppercase = 1 } page.20 = TEXT page.20 { value = Hello World! stdWrap.postUserFunc = MyVendor\SitePackage\UserFunctions\YourClass->reverseString stdWrap.postUserFunc.uppercase = 1 stdWrap.postUserFunc.typolink = 11 }
Your methods will get the parameters
$content
and$conf
(in that order) and need to return a string.EXT:site_package/Classes/UserFunctions/YourClass.php<?php declare(strict_types=1); namespace MyVendor\SitePackage\UserFunctions; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; final class YourClass { /* * Reference to the parent (calling) cObject set from TypoScript */ private ContentObjectRenderer $cObj; public function setContentObjectRenderer( ContentObjectRenderer $cObj, ): void { $this->cObj = $cObj; } /** * Custom method for data processing. Also demonstrates * how this gives us the ability to use methods in the * parent object. * * @param string $content holds the value to be processed. * @param array $conf TypoScript properties passed to this method. */ public function reverseString( string $content, array $conf, ServerRequestInterface $request, ): string { $content = strrev($content); if (isset($conf['uppercase']) && $conf['uppercase'] === '1') { // Use the method caseshift() from ContentObjectRenderer $content = $this->cObj->caseshift($content, 'upper'); } if (isset($conf['typolink'])) { // Use the method typoLink() from ContentObjectRenderer $content = $this->cObj ->typoLink($content, ['parameter' => $conf['typolink']]); } return $content; } }
For
page.
: the content which exists when10 post
is executed, will be processed by the functionUser Func reverse
in the classString () Your
. The result will beClass !DLROW OLLEH
.For
page.
the result will be the same, but wrapped into a link to the page with ID 11. The result will be20 <a href="/
.path/ to/ page/ id/ 11">!DLROW OLLEH</ a> Note how in the PHP code
$this->c
, the reference to the callingObj c
, uses functions fromObject Content
class.Object Renderer
postUserFuncInt
-
- Type
- function name
Calls the provided PHP function. If you specify a function name with '->' it will be interpreted as a call to a class method.
Two parameters are sent to the PHP function: a content variable containing the current content (this is the value that will be processed) and subproperties of
post
.User Func Int The result will be rendered non-cached outside the main page-rendering. See the
c
USER_INT description.Object Supplied by Jens Ellerbrock
prefixComment
-
Prefixes content with an HTML comment. The second part of the input string (divided by "|") is the comment and the first part is an integer denoting how many trailing tabs to put in front of the comment on a new line.
The content is parsed through
insert
.Data ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscriptprefixComment = 2 | CONTENT ELEMENT, uid:{field:uid}/{field:CType}
Copied!Will indent the comment by 1 tab (and the next line by 2+1 tabs)
Properties for sanitizing and caching data
htmlSanitize
-
- Type
- boolean / array with key "build"
This property is responsible for sanitization and removal of XSS from markup. It strips tags, attributes and values that are not explicitly allowed.
html
- whether to invoke sanitization (enabled by default when invoked bySanitize = [boolean] std
).Wrap. parse Func html
- defines which builder to use (must be an instance ofSanitize. build = [string] \TYPO3\
) for building aHtml Sanitizer\ Builder\ Builder Interface \TYPO3\
instance using a particularHtml Sanitizer\ Sanitizer \TYPO3\
. It can either be a fully qualified class name or the name of a preset as defined inHtml Sanitizer\ Behavior $GLOBALS
- the default is['TYPO3_ CONF_ VARS'] ['SYS'] ['html Sanitizer'] \TYPO3\
.CMS\ Core\ Html\ Default Sanitizer Builder
ExamplesEXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10 { value = <div><img src="invalid.file" onerror="alert(1)"></div> htmlSanitize = 1 }
Copied!will result in the following output:
<div><img src="invalid.file"></div>
Copied!The following code is equivalent to the above, but specifies a builder:
EXT:site_package/Configuration/TypoScript/setup.typoscript10 = TEXT 10 { value = <div><img src="invalid.file" onerror="alert(1)"></div> htmlSanitize = 1 // Use either "default" for the default builder htmlSanitize.build = default // or use the full class name of the default builder // htmlSanitize.build = TYPO3\CMS\Core\Html\DefaultSanitizerBuilder }
Copied!
cache
-
- Type
- cache
Caches rendered content in the caching framework.
Properties for debugging data
debug
Attention
Only use this for debugging during development, otherwise output can break.
debugFunc
Attention
Only use this for debugging during development, otherwise output can break.
debugData
Attention
Only use this for debugging during development, otherwise output can break.
Example
Content object "TEXT" containing property "value":
10 = TEXT
10.value = some text
10.stdWrap.case = upper
Here the content in object "10" is converted into uppercase before it is returned.