stdWrap

When a data type is set to "type /stdWrap" it means that the value is parsed through the stdWrap function with the properties of the value as parameters.

Properties

Properties for getting data

setContentToCurrent

Property
setContentToCurrent
Data type
boolean / stdWrap
Description
Sets the current value to the incoming content of the function.

addPageCacheTags

Property
addPageCacheTags
Data type
string / stdWrap
Description
Comma-separated list of cache tags, which should be added to the page cache.
Example
addPageCacheTags = pagetag1,pagetag2,pagetag3
Copied!

This will add the tags "pagetag1", "pagetag2" and "pagetag3" to the according cached pages in cache_pages.

Pages, which have been cached with a tag, can be deleted from cache again with the TSconfig option TCEMAIN.clearCacheCmd.

setCurrent

Property
setCurrent
Data type
string / stdWrap
Description
Sets the "current"-value. This is normally set from some outside routine, so be careful with this. But it might be handy to do this

lang

Property
lang
Data type
Array of language keys / stdWrap
Description
This is used to define optional language specific values based on the current site language.
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.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

Property
data
Data type
Data / getText / stdWrap

field

Property
field
Data type
Field name / stdWrap
Description

Sets the content to the value of the according field (which comes from $cObj->data[*field*]).

Note: $cObj->data changes depending on the context. See the description for the data type "Data / getText"/field!

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10.field = title
Copied!

This sets the content to the value of the field "title".

You can also check multiple field names, if you divide them by "//".

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10.field = nav_title // title
Copied!

Here the content from the field nav_title will be returned unless it is a blank string. If a blank string, the value of the title field is returned.

current

Property
current
Data type
boolean / stdWrap
Description
Sets the content to the "current"-value (see ->split)

cObject

Property
cObject
Data type
Content Objects (cObject)
Description
Loads content from a content object.

numRows

Property
numRows
Data type
->numRows / stdWrap
Description
Returns the number of rows resulting from the supplied SELECT query.

preUserFunc

Property
preUserFunc
Data type
function name
Description

Calls the provided PHP function. If you specify the name with a '->' in it, then it is interpreted as a call to a method in a class.

Two parameters are sent to the PHP function: As first parameter a content variable, which contains the current content. This is the value to be processed. As second parameter any sub-properties of preUserFunc are provided to the function.

See postUserFunc.

Properties for overriding and conditions

override

Property
override
Data type
string / stdWrap
Description
if "override" returns something else than "" or zero (trimmed), the content is loaded with this!

preIfEmptyListNum

Property
preIfEmptyListNum
Data type
(as "listNum" below)
Description
(as "listNum" below)

ifNull

Property
ifNull
Data type
string / stdWrap
Description
If the content is null (NULL type in PHP), the content is overridden with the value defined here.
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 = COA_INT
page.10 {
   10 = TEXT
   10 {
      stdWrap.field = description
      stdWrap.ifNull = No description defined.
   }
}
Copied!

This example shows the content of the field description or, if that field contains the value NULL, the text "No description defined.".

ifEmpty

Property
ifEmpty
Data type
string / stdWrap
Description
If the trimmed content is empty at this point, the content is loaded with ifEmpty. Zeros are treated as empty values!

ifBlank

Property
ifBlank
Data type
string / stdWrap
Description
Same as ifEmpty but the check is done against ''. Zeros are not treated as blank values!

listNum

Property
listNum
Data type
integer +calc +"last" +"rand" / stdWrap
Description

Explodes the content with "," (comma) and the content is set to the item[value].

Special keyword: last
Is set to the last element of the array!
Special keyword: rand
Returns a random item out of a list.
.splitChar (string):

Defines the string used to explode the value. If splitChar is an integer, the character with that number is used (e.g. "10" to split lines...).

Default: "," (comma)

.stdWrap (stdWrap properties):
stdWrap properties of the listNum...
Examples

We have a value of "item 1, item 2, item 3, item 4":

This would return "item 3"

EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 = TEXT
page.10.value = item 1, item 2, item 3, item 4
page.10.listNum = last – 1
Copied!

That way the subtitle field to be displayed is chosen randomly upon every reload:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page.5 = COA_INT
page.5 {
   10 = TEXT
   10 {
      stdWrap.field = subtitle
      stdWrap.listNum = rand
   }
}
Copied!

trim

Property
trim
Data type
boolean / stdWrap
Description
If set, the PHP-function trim() will be used to remove whitespaces around the value.

strPad

Property
strPad
Data type
strPad
Description
Pads the current content to a certain length. You can define the padding characters and the side(s), on which the padding should be added.

stdWrap

Property
stdWrap
Data type
stdWrap
Description
Recursive call to the stdWrap function.

required

Property
required
Data type
boolean / stdWrap
Description

This flag requires the content to be set to some value after any content-import and treatment that might have happened until now (data, field, current, listNum, trim). Zero is not regarded as empty! Use "if" instead!

If the content is empty, "" is returned immediately.

if

Property
if
Data type
if
Description
If the if-object returns false, stdWrap returns "" immediately.

fieldRequired

Property
fieldRequired
Data type
Field name / stdWrap
Description
The value in this field must be set.

Properies for parsing data

csConv

Property
csConv
Data type
string / stdWrap
Description
Convert the charset of the string from the charset given as value to the current rendering charset of the frontend (UTF-8).

parseFunc

Property
parseFunc
Data type
object path reference / parseFunc / stdWrap
Description

Processing instructions for the content.

Note: If you enter a string as value, this will be taken as a reference to an object path globally in the TypoScript object tree. This will be the basis configuration for parseFunc merged with any properties you add here. It works exactly like references does for content elements.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 {
    parseFunc = < lib.parseFunc_RTE
    parseFunc.tags.myTag = TEXT
    parseFunc.tags.myTag.value = This will be inserted when &lt;myTag&gt; is found!
}
Copied!
Sanitization

New in version 9.5.29/10.4.19

stdWrap.htmlSanitize is enabled by default when stdWrap.parseFunc is invoked. This also includes the Fluid Viewhelper <f:format.html>, since it invokes parseFunc directly using lib.parseFunc_RTE.

The following example shows how to disable the sanitization behavior that is enabled by default. This is not recommended, but it can be disabled when required.

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

Since any invocation of stdWrap.parseFunc triggers HTML sanitization automatically; unless explicitly disabled the following example causes a lot of generated markup to be sanitized and can be solved by explicitly disabling it with htmlSanitize = 0.

EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = FLUIDTEMPLATE
10 {
    templateRootPaths {
        // ...
    }
    variables {
        // ...
    }
    stdWrap.parseFunc {
        // replace --- with soft-hyphen
        short.--- = &shy;
        // sanitization of ALL MARKUP is NOT DESIRED here
        htmlSanitize = 0
    }
}
Copied!

HTMLparser

Property
HTMLparser
Data type
boolean / HTMLparser / stdWrap
Description

This object allows you to parse the HTML-content and perform all kinds of 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

Property
split
Data type
split / stdWrap

replacement

Property
replacement
Data type
replacement / stdWrap
Description
Performs an ordered search/replace on the current content with the possibility of using PCRE regular expressions. An array with numeric indices defines the order of actions and thus allows multiple replacements at once.

prioriCalc

Property
prioriCalc
Data type
boolean / stdWrap
Description

Calculation of the value using operators -+*/%^ plus respects priority to + and - operators and parenthesis levels ().

. (period) is decimal delimiter.

Returns a doublevalue.

If prioriCalc is set to "intval" an integer is returned.

There is no error checking and division by zero or other invalid values may generate strange results. Also you should use a proper syntax because future modifications to the function used may allow for more operators and features.

Examples
Example Output for different calculations
100%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

Property
char
Data type
integer / stdWrap
Description

Content is set to chr(*value*). 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:

$content = chr((int)$conf['char']);
Copied!

intval

Property
intval
Data type
boolean / stdWrap
Description

PHP function intval() returns an integer:

$content = intval($content);
Copied!

hash

Property
hash
Data type
string / stdWrap
Description
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.
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 = TEXT
page.10 {
   value = test@example.org
   stdWrap.hash = md5
   stdWrap.wrap = <img src="https://www.gravatar.com/avatar/|" />
}
Copied!

round

Property
round
Data type
round / stdWrap
Description
Round the value with the selected method to the given number of decimals.

numberFormat

Property
numberFormat
Data type
numberFormat
Description
Format a float value to any number format you need (e.g. useful for prices).

date

Property
date
Data type
date-conf / stdWrap
Description

The content should be data-type "UNIX-time". Returns the content formatted as a date. See the PHP manual (datetime.format) for the format codes.

$content = date($conf['date'], $content);
Copied!

Properties:

.GMT: If set, the PHP function gmdate() will be used instead of date().

Example

Render in human readable form:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 = TEXT
page.10.value {
   # format like 2017-05-31 09:08
   field = tstamp
   date = Y-m-d H:i
}
Copied!

strtotime

Property
strtotime
Data type
string
Description

Allows conversion of formatted dates to timestamp, e.g. to perform date calculations.

Possible values are 1 or any time string valid as first argument of the PHP strtotime() function.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
lib.date_as_timestamp = TEXT
lib.date_as_timestamp {
   value = 2015-04-15
   strtotime = 1
}
Copied!
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
lib.next_weekday = TEXT
lib.next_weekday {
   data = GP:selected_date
   strtotime = + 2 weekdays
   strftime = %Y-%m-%d
}
Copied!

strftime

Property
strftime
Data type
strftime-conf / stdWrap
Description

Very similar to "date", but using a different format. See the PHP manual (strftime) for the format codes.

This formatting is useful if the locale is set in advance in the CONFIG object. See there.

Properties:

.charset
Can be set to the charset of the output string if you need to convert it to UTF-8. Default is to take the intelligently guessed charset from TYPO3\CMS\Core\Charset\CharsetConverter.
.GMT
If set, the PHP function gmstrftime() will be used instead of strftime().

age

Property
age
Data type
boolean or string / stdWrap
Description

If enabled with a "1" (number, integer) the content is seen as a date (UNIX-time) and the difference from present 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 limits between which layout is used are 60 minutes, 24 hours and 365 days.

If you set this property with a 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 format
min| hrs| days| yrs| min| hour| day| year
Copied!

Set another string if you want to change the units. You may include the "-signs. They are removed anyway, but they make sure that a space which you might want between the number and the unit stays.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
lib.ageFormat = TEXT
lib.ageFormat.stdWrap.data = page:tstamp
lib.ageFormat.stdWrap.age = " Minuten | Stunden | Tage | Jahre | Minute | Stunde | Tag | Jahr"
Copied!

case

Property
case
Data type
case / stdWrap
Description

Converts case

Uses "UTF-8" for the operation.

bytes

Property
bytes
Data type
boolean / stdWrap
Default
iec, 1024
Description

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 like '1.53 KiB' or '1.00 MiB'. Learn about common notations at Wikipedia "Kibibyte". IEC naming with base 1024 is the default. Use sub-properties for customisation.

.labels = iec
This is the default. IEC labels and base 1024 are used. Built in IEC labels are " | Ki| Mi| Gi| Ti| Pi| Ei| Zi| Yi". You need to append a final string like 'B' or '-Bytes' yourself.
.labels = si
In this case SI labels and base 1000 are used. Built in IEC labels are " | k| M| G| T| P| E| Z| Y". You need to append a final string like 'B' yourself.
.labels = "..."
Custom values can be defined as well like with .labels = " Byte| Kilobyte| Megabyte| Gigabyte". Use a vertical bar to separate the labels. Enclose the whole string in double quotes.
.base = 1000
Only with custom labels you can choose to set a base of1000. All other values, including the default, mean base 1024.
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 {
   value = abc
   bytes = 1
}

will show `0` but may raise a warning or an exception.
Copied!

Examples Output value 1000 without special formatting. Shows 1000:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page = 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.typoscript
page = 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 KiB:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page = 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.typoscript
page = 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.typoscript
page = 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.typoscript
page = 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 (kB):

EXT:site_package/Configuration/TypoScript/setup.typoscript
page = 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 (KiB):

EXT:site_package/Configuration/TypoScript/setup.typoscript
page = 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

Property
substring
Data type
[p1], [p2] / stdWrap
Description

Returns the substring with [p1] and [p2] sent as the 2nd and 3rd parameter to the PHP mb_substr function.

Uses "UTF-8" for the operation.

cropHTML

Property
cropHTML
Data type
string / stdWrap
Description

Crops the content to a certain length. In contrast to stdWrap.crop it respects HTML tags. It does not crop inside tags and closes open tags. Entities (like ">") are counted as one char. See stdWrap.crop below for a syntax description and examples.

Note that stdWrap.crop should not be used if stdWrap.cropHTML is already used.

stripHtml

Property
stripHtml
Data type
boolean / stdWrap
Description
Strips all HTML tags.

crop

Property
crop
Data type
string / stdWrap
Description

Crops the content to a certain length.

You can define up to three parameters, of which the third one is optional. The syntax is: [numbers of characters to keep] | [ellipsis] | [keep whole words]

numbers of characters to keep (integer): Define the number of characters you want 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 signs to be added instead of the part, which was cropped of. If the number of characters was positive, the string will be prepended with the ellipsis, if it was negative, the string will be appended with the ellipsis.

keep whole words (boolean): If set to 0 (default), the string is always cropped directly after the defined number of characters. If set to 1, only complete words are kept. Then a word, which would normally be cut in the middle, is removed completely.

Examples

20 | ... => 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 | ... | 1 => 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 remains of that word is removed.

Uses "UTF-8" for the operation.

rawUrlEncode

Property
rawUrlEncode
Data type
boolean / stdWrap
Description
Passes the content through the PHP function rawurlencode().

htmlSpecialChars

Property
htmlSpecialChars
Data type
boolean / stdWrap
Description

Passes the content through the PHP function htmlspecialchars().

Additional property preserveEntities will preserve entities so only non-entity characters are affected.

encodeForJavaScriptValue

Property
encodeForJavaScriptValue
Data type
boolean / stdWrap
Description

Encodes content to be used safely inside strings in JavaScript. Characters, which can cause problems inside JavaScript strings, are replaced with their encoded equivalents. The resulting string is already quoted with single quotes.

Passes the content through the core function \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = TEXT
10.stdWrap {
      data = GP:sWord
      encodeForJavaScriptValue = 1
      wrap = setSearchWord(|);
}
Copied!

doubleBrTag

Property
doubleBrTag
Data type
string / stdWrap
Description
All double-line-breaks are substituted with this value.

br

Property
br
Data type
boolean / stdWrap
Description
Pass the value through the PHP function nl2br(). This converts each line break to a <br /> or a <br> tag depending on doctype.

brTag

Property
brTag
Data type
string / stdWrap
Description
All ASCII codes of "10" (line feed, LF) are substituted with the value, which has been provided in this property.

encapsLines

Property
encapsLines
Data type
encapsLines / stdWrap
Description
Lets you split the content by chr(10) and process each line independently. Used to format content made with the RTE.

keywords

Property
keywords
Data type
boolean / stdWrap
Description
Splits the content by characters "," ";" and php:chr(10) (return), trims each value and returns a comma-separated list of the values.

innerWrap

Property
innerWrap
Data type
wrap / stdWrap
Description
Wraps the content.

innerWrap2

Property
innerWrap2
Data type
wrap / stdWrap
Description
Same as innerWrap (but watch the order in which they are executed).

preCObject

Property
preCObject
Data type
Content Objects (cObject)
Description
cObject prepended the content.

postCObject

Property
postCObject
Data type
Content Objects (cObject)
Description
cObject appended the content.

wrapAlign

Property
wrapAlign
Data type
align / stdWrap
Description
Wraps content with <div style=text-align:[*value*];"> | </div> if align is set.

wrap

Property
wrap
Data type
wrap /+.splitChar / stdWrap
Description
splitChar defines an alternative splitting character (default is "|" - the vertical line)

noTrimWrap

Property
noTrimWrap
Data type
"special" wrap /+.splitChar / stdWrap
Description

This wraps the content without trimming the values. That means that surrounding whitespaces stay included! Note that this kind of wrap does not only need a special character in the middle, but that it also needs the same special character to begin and end the wrap (default for all three is "|").

Additional property:

splitChar

Can be set to define an alternative special character. stdWrap is available. Default is "|" - the vertical line. This sub-property is useful in cases when the default special character would be recognized by optionSplit (which takes precedence over noTrimWrap).

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10.noTrimWrap = | val1 | val2 |
Copied!

In this example the content with the values val1 and val2 will be wrapped; including the whitespaces.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 {
   noTrimWrap = ^ val1 ^ val2 ^ || ^ val3 ^ val4 ^
   noTrimWrap.splitChar = ^
}
Copied!

optionSplit will use the "||" to have two subparts in the first part. In each subpart noTrimWrap will then use the "^" as special character.

wrap2

Property
wrap2
Data type
wrap /+.splitChar / stdWrap
Description
same as wrap (but watch the order in which they are executed)

dataWrap

Property
dataWrap
Data type
mixed / stdWrap
Description
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.
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10.dataWrap = <div id="{tsfe : id}"> | </div>
Copied!

This will produce a <div> tag around the content with an id attribute that contains the number of the current page.

prepend

Property
prepend
Data type
Content Objects (cObject)
Description
cObject prepended to content (before)

append

Property
append
Data type
Content Objects (cObject)
Description
cObject appended to content (after)

wrap3

Property
wrap3
Data type
wrap /+.splitChar / stdWrap
Description
same as wrap (but watch the order in which they are executed)

orderedStdWrap

Property
orderedStdWrap
Data type
Array of numeric keys with / stdWrap each
Description
Execute multiple stdWrap statements in a freely selectable order. The order is determined by the numeric order of the keys. This allows to use multiple stdWrap statements without having to remember the rather complex sorting order in which the stdWrap functions are executed.
Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = TEXT
10.value = a
10.stdWrap.orderedStdWrap {
   30.wrap = |.

   10.wrap = is | working
   10.innerWrap = &nbsp;|&nbsp;

   20.wrap = This|solution
   20.stdWrap.wrap = &nbsp;|&nbsp;
}
Copied!

In this example orderedStdWrap is executed on the value "a". 10.innerWrap is executed first, followed by 10.wrap. Then the next key is processed which is 20. Afterwards 30.wrap is executed on what already was created.

This results in "This is a working solution."

outerWrap

Property
outerWrap
Data type
wrap / stdWrap
Description
Wraps the complete content

insertData

Property
insertData
Data type
boolean / stdWrap
Description
If set, then the content string is parsed like dataWrap above.
Example

Displays the page title:

EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = 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!

postUserFunc

Property
postUserFunc
Data type
function name
Description

Calls the provided PHP function. If you specify the name with a '->' in it, then it is interpreted as a call to a method in a class.

Two parameters are sent to the PHP function: As first parameter a content variable, which contains the current content. This is the value to be processed. As second parameter any sub-properties of postUserFunc are provided to the function.

The description of the cObject USER contains some more in-depth information.

Example

You can paste this example directly into a new template record:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page = PAGE
page.typeNum = 0

page.10 = TEXT
page.10 {
   value = Hello World!
   stdWrap.postUserFunc = Vendor\SitePackage\UserFunctions\YourClass->reverseString
   stdWrap.postUserFunc.uppercase = 1
}

page.20 = TEXT
page.20 {
   value = Hello World!
   stdWrap.postUserFunc = Vendor\SitePackage\UserFunctions\YourClass->reverseString
   stdWrap.postUserFunc.uppercase = 1
   stdWrap.postUserFunc.typolink = 11
}
Copied!

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
namespace Vendor\SitePackage\UserFunctions;

/**
 * Example of a method in a PHP class to be called from TypoScript
 */
final class YourClass
{
   /*
    * Reference to the parent (calling) cObject set from TypoScript
    *
    * @var ContentObjectRenderer
    */
   private $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 When custom methods are used for data processing (like in stdWrap functions), the $content variable will hold the value to be processed. When methods are meant to return some generated content (like in USER and USER_INT objects), this variable is empty.
    * @param  array  TypoScript properties passed to this method.
    * @return string The input string reversed. If the TypoScript property "uppercase" was set, it will also be in uppercase. May also be linked.
    */
   public function reverseString(string $content, array $conf): 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;
   }
}
Copied!

For page.10 the content, which is present when postUserFunc is executed, will be given to the PHP function reverseString(). The result will be !DLROW OLLEH.

The content of page.20 will be processed by the function reverseString() from the class YourClass. This also returns the text !DLROW OLLEH, but wrapped into a link to the page with the ID 11. The result will be <a href="/path/to/page/id/11">!DLROW OLLEH</a>.

Note how in the second example $this->cObj, the reference to the calling cObject, is utilised to use functions from ContentObjectRenderer class!

postUserFuncInt

Property
postUserFuncInt
Data type
function name
Description

Calls the provided PHP function. If you specify the name with a '->' in it, then it is interpreted as a call to a method in a class.

Two parameters are sent to the PHP function: As first parameter a content variable, which contains the current content. This is the value to be processed. As second parameter any sub-properties of postUserFuncInt are provided to the function.

The result will be rendered non-cached, outside the main page-rendering. Please see the description of the cObject USER_INT.

Supplied by Jens Ellerbrock

prefixComment

Property
prefixComment
Data type
string / stdWrap
Description

Prefixes content with an HTML comment with the second part of input string (divided by "|") where first part is an integer telling how many trailing tabs to put before the comment on a new line.

The content is parsed through insertData.

Example
EXT:site_package/Configuration/TypoScript/setup.typoscript
prefixComment = 2 | CONTENT ELEMENT, uid:{field:uid}/{field:CType}
Copied!

Will indent the comment with 1 tab (and the next line with 2+1 tabs)

editIcons

Deprecated since version 11.4

With the extraction of the feedit extension from TYPO3 Core in v10 this related TypoScript property have been rendered unused. Extensions that provide a frontend editing approach should implement this on their own.

Property
editIcons
Data type
string / stdWrap
Description
See Migration from the build-in EDITPANEL.

editPanel

Deprecated since version 11.4

With the extraction of the feedit extension from TYPO3 Core in v10 this related TypoScript property have been rendered unused. Extensions that provide a frontend editing approach should implement this on their own.

Property
editPanel
Data type
boolean / EDITPANEL
Description
See Migration from the build-in EDITPANEL.

htmlSanitize

New in version 9.5.29/10.4.19

Property
htmlSanitize
Data type
boolean / array with key "build"
Description

The property controls the sanitization and removal of XSS from markup. It strips tags, attributes and values that are not explicitly allowed.

  • htmlSanitize = [boolean]: whether to invoke sanitization (enabled per default when invoked via stdWrap.parseFunc).
  • htmlSanitize.build = [string]: defines which specific builder (must be an instance of \TYPO3\HtmlSanitizer\Builder\BuilderInterface) to be used for building a \TYPO3\HtmlSanitizer\Sanitizer instance using a particular \TYPO3\HtmlSanitizer\Behavior. This can either be a fully qualified class name or the name of a preset as defined in $GLOBALS['TYPO3_CONF_VARS']['SYS']['htmlSanitizer'] - per default, \TYPO3\CMS\Core\Html\DefaultSanitizerBuilder is used.
Examples
EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = 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 above, but with a builder specified:

EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = 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

Property
cache
Data type
cache
Description
Caches rendered content in the caching framework.

debug

Property
debug
Data type
boolean / stdWrap
Description
Prints content with HTMLSpecialChars() and <pre></pre>: Useful for debugging which value stdWrap actually ends up with, if you are constructing a website with TypoScript.

debugFunc

Property
debugFunc
Data type
boolean / stdWrap
Description

Prints the content directly to browser with the debug() function.

Set to value "2" the content will be printed in a table which looks nicer.

debugData

Property
debugData
Data type
boolean / stdWrap
Description
Prints the current data-array, $cObj->data, directly to browser. This is where field gets data from.

Example

Example with the property "value" of the content object "TEXT":

EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = TEXT
10.value = some text
10.stdWrap.case = upper
Copied!

Here the content of the object "10" is uppercased before it is returned.

Content-supplying properties of stdWrap

stdWrap contains properties which determine what is applied. The properties are listed below.

The properties are parsed in the listed order. The properties data, field, current, cObject (in that order!) are special as they are used to import content from variables or arrays.

If you want to study this further please refer to typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php, where you will find the function stdWrap() and the array $stdWrapOrder, which represents the exact order of execution.

Note that the stdWrap property "orderedStdWrap" allows you to execute multiple stdWrap functions in a freely selectable order.

The above example could be rewritten to this:

EXT:site_package/Configuration/TypoScript/setup.typoscript
10 = TEXT
10.value = some text
10.stdWrap.case = upper
10.stdWrap.field = header
Copied!

Now the line 10.value = some text is obsolete, because the whole value is "imported" from the field called "header" from the $cObj->data-array.