Simple data types¶
The values assigned to properties in TypoScript are often of a specific format. These formats are described in this chapter.
For example, if a value is defined as the type <tag>
, HTML code has to be
supplied. If it is of the type resource
, it's a reference to a file from
the resource-field in the template. If the type is Graphic
, a
color-definition is expected and an HTML color code or comma-separated
RGB-values have to be provided.
The following is a list of available data types, their usage, purpose and examples.
align¶
-
align
¶ -
- Default
left
- Allowed values
left
,center
,right
Decides about alignment.
boolean¶
-
boolean
¶ -
Possible values for boolean variables are
1
and0
meaning TRUE and FALSE.Everything else is evaluated to one of these values by PHP: Non-empty strings (except
0
[zero]) are treated as TRUE, empty strings are evaluated to FALSE.Examplesdummy.enable = 0 # false, preferred notation dummy.enable = 1 # true, preferred notation dummy.enable = # false, because the value is empty
Copied!
case¶
-
case
¶ -
Do a case conversion.
Possible values:Value Effect upper
Convert all letters of the string to upper case lower
Convert all letters of the string to lower case capitalize
Uppercase the first character of each word in the string ucfirst
Convert the first letter of the string to upper case lcfirst
Convert the first letter of the string to lower case uppercamelcase
Convert underscored upper_
tocamel_ case Upper
Camel Case lowercamelcase
Convert underscored lower_
tocamel_ case lower
Camel Case ExampleCode:
10 = TEXT 10.value = Hello world! 10.case = upper
Copied!Result:
HELLO WORLD!
Copied!
date-conf¶
-
date-
¶conf -
Used to format a date, see PHP function
date
. See the documentation of allowed date time formats in PHP.() Examplepage.10.date-conf = d-m-y
Copied!
degree¶
-
degree
¶ -
-90
to90
, integersExample:
45
dir¶
-
dir
¶ -
Syntax
[path relative to the web root of the site] | [list of valid extensions] | [sorting: name, size, ext, date] | [reverse: "r"] | [return full path: boolean]
Files matching are returned in a comma-separated string.
ExampleThis example returns a list of all pdf, gif and jpg-files from
fileadmin/
sorted by their name reversely and with the full path (withfiles/ fileadmin/
prepended):files/ page.10.dir = fileadmin/files/ | pdf,gif,jpg | name | r | true
Copied!
function name¶
-
function name
¶ -
Indicates a function or method in a class to call. See more information at the USER cObject.
If no namespaces are used, then the class or function name, but not the method name, should probably be prefixed with
user_
. The prefix can be changed in the$GLOBALS
config though. The function / method is normally called with 2 parameters,['TYPO3_ CONF_ VARS'] $conf
which is the TypoScript configuration and$content
, some content to be processed and returned.If no namespaces are used and if a method in a class is called, it is checked (when using the
USER
/USER_
objects) whether a class with the same name, but prefixed withINT ux_
is present and if so, this class is instantiated instead. See the document "Inside TYPO3" for more information on extending classes in TYPO3!ExamplesMethod in namespaced class. This is the preferred version:
lib.someThing = USER_INT lib.someThing.userFunc = MyVendor\MyExtension\SomeNamespace\SomeClass->someFunction
Copied!<?php namespace MyVendor\MyExtension\SomeNamespace; use Psr\Http\Message\ServerRequestInterface; class SomeClass { /** * @param string $content Empty string (no content to process) * @param array $conf TypoScript configuration */ public function someFunction(string $content, array $conf, ServerRequestInterface $request): string { $changedContent = $content; // Do something return $changedContent; } }
Single Function:
user_reverseString
Copied!Method in class without namespace:
user_yourClass->reverseString
Copied!
getText¶
The getText data type is some kind of tool box allowing to retrieve values from a variety of sources. Read more: Data / getText
GraphicColor¶
-
Graphic
¶Color -
Syntax:
[colordef] : [modifier]
Where modifier can be an integer which is added or subtracted to the three RGB-channels or a floating point with an
*
before, which will then multiply the values with that factor.The color can be given as HTML-color or as a comma-separated list of RGB-values (integers). An extra parameter can be given, that will modify the color mathematically:
Examplesred
(HTML color)#ffeecc
(HTML color as hexadecimal notation)255,0,255
(HTML color as decimal notation)
Extra:
red : *0.
("red" is darkened by factor 0.8)8 #ffeecc : +16
("ffeecc" is going to #fffedc because 16 is added)
imageExtension¶
-
image
¶Extension -
Image extensions can be anything among the allowed types defined in the global variable
$GLOBALS
. Standard is pdf, gif, jpg, jpeg, tif, bmp, ai, pcx, tga, png.['TYPO3_ CONF_ VARS'] ['GFX'] ['imagefile_ ext'] The value "web" is special. This will ensure that an image is converted to a web image format (gif or jpg) if it happens not to be already!
Examplesjpg
web (gif or jpg ..)
imgResource¶
-
img
¶Resource -
-
A resource plus imgResource properties.
Filetypes can be anything among the allowed types defined in the configuration variable
$GLOBALS
. Standard is pdf, gif, jpg, jpeg, tif, bmp, ai, pcx, tga, png.['TYPO3_ CONF_ VARS'] ['GFX'] ['imagefile_ ext'] - A GIFBUILDER object. See the object reference for GIFBUILDER.
ExamplesHere "file" is an imgResource:
10 = IMAGE 10 { file = fileadmin/toplogo.gif file.width = 200 }
Copied!GIFBUILDER:
10 = IMAGE 10.file = GIFBUILDER 10.file { # GIFBUILDER properties here... }
Copied! -
integer¶
path¶
-
path
¶ -
Path relative to the root directory from which we operate. Also resolves
EXT:
syntax.Examplepage.10.settings.somePath = fileadmin/stuff/
Copied!
pixels¶
-
pixels
¶ -
pixel-distance
Examplepage.10.someWidth = 345
Copied!
positive integer¶
-
positive integer
¶
resource¶
-
resource
¶ -
If the value contains a "/", it is expected to be a reference (absolute or relative) to a file in the file system. There is no support for wildcard characters in the name of the reference.
ExampleReference to a file in the file system:
page.10.settings.someFile = fileadmin/picture.gif
Copied!
strftime-conf¶
-
strftime-
¶conf -
See function strftime on php.net.
string¶
-
string
¶ -
Sometimes used generally though another type would have been more appropriate, like "align".
ExampleThe quick brown fox jumps over the lazy dog.
tag¶
-
tag
¶ -
An HTML tag.
Examplepage.10.settings.bodyTag = <body lang="de">
Copied!
tag-params¶
-
tag-
¶params -
Parameters for a tag.
ExamplesFor <frameset>-params:
page.10.settings.someParams = border="0" framespacing="0"
Copied!
target¶
-
target
¶ -
Examples
_top
,_blank
,content
Target in an
<a>
-tag.This is normally the same value as the name of the root-level object that defines the frame.
wrap¶
-
wrap
¶ -
- Syntax
-
<...> | </...>
Used to wrap something. The vertical bar ("|") is the place, where your content will be inserted; the parts on the left and right of the vertical line are placed on the left and right side of the content.
Spaces between the wrap-parts and the divider ("|") are trimmed off from each part of the wrap.
If you want to use more sophisticated data functions, then you should use
std
instead ofWrap. data Wrap wrap
.A
wrap
is processed and rendered as the last of the other components of a cObject.ExamplesThis will cause the value to be wrapped in a p-tag coloring the value red:
page.10.stdWrap.wrap = <p class="bg-red"> | </p>
Copied!