Login / Status
developer.Resource
Home . Documentation . Document Library . References
Sponsors
hosted by punkt.deTYPO3 and Open Source MagazineAOE Media

Chapter 5. Functions:

5.1. stdWrap:

This function is often added as properties to values in TypoScript.

Example with the content-object, "HTML":

10 = HTML
10.value = some text
10.value.case = upper

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

stdWrap properties are executed in the order they appear in the table below. If you want to study this further please refer to typo3/sysext/cms/tslib/class.tslib_content.php, function stdWrap().

Content-supplying properties of stdWrap:

The properties in this table is 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. The above example could be rewritten to this:

10 = HTML
10.value = some text
10.value.case = upper
10.value.field = header

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.

Property:

Data type:

Description:

Default:

Get data:

   

setContentToCurrent

boolean

Sets the current value to the incoming content of the function.

setCurrent

string /stdWrap

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

Array of language keys

This is used to define optional language specific values.

If the global language key set by the ->config property .language is found in this array, then this value is used instead of the default input value to stdWrap.

Example:

config.language = de

page.10 = TEXT

page.10.value = I am a Berliner!

page.10.lang.de = Ich bin ein Berliner!

Output will be “Ich bin...” instead of “I am...”

data

getText

field

fieldname

Sets the content to the value $cObj->data[field]

Example: Set content to the value of field "title": ".field = title"

$cObj->data changes. See the description for the data type "getText"/field!

Note: You can also divide fieldnames by “//”. Say, you set “nav_title // title” as the value, then the content from the field nav_title will be returned unless it is a blank string, in which case the title-field's value is returned.

current

boolean

Sets the content to the "current"-value (see ->split)

cObject

cObject

Loads content from a content-object

numRows

->numRows

Returns the number of rows resulting from the select

filelist

dir /stdWrap

Reads a directory and returns a list of files.

The value is exploded by "|" into parameters:

1: The path

2: comma-list of allowed extensions (no spaces between); if empty all extensions goes.

3: sorting: name, size, ext, date, mdate (modification date)

4: reverse: Set to "r" if you want a reversed sorting

5: fullpath_flag: If set, the filelist is returned with complete paths, and not just the filename

preUserFunc

function-name

Calling a PHP-function or method in a class, passing the current content to the function as first parameter and any properties as second parameter.

See .postUserFunc

Override / Conditions:

   

override

string /stdWrap

if "override" returns something else than "" or zero (trimmed), the content is loaded with this!

preIfEmptyListNum

(as "listNum" below)

(as "listNum" below)

ifEmpty

string /stdWrap

if the content is empty (trimmed) at this point, the content is loaded with "ifEmpty". Zeros are treated as empty values!

ifBlank

string /stdWrap

Same as "ifEmpty" but the check is done using strlen().

listNum

int

+calc

+"last"

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!

.splitChar (string):

Defines the string used to explode the value. If splitChar is an integer, the character with that number is used (eg. "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":

.listNum = last - 1

trim

PHP-function trim(); Removes whitespace around value

stdWrap

->stdWrap

Recursive call to stdWrap function

required

boolean

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

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

if

->if

If the if-object returns false, stdWrap returns "" immediately

fieldRequired

fieldname

value in this field MUST be set

Parse data:

   

csConv

string

Convert the charset of the string from the charset given as value to the current rendering charset of the frontend (renderCharset).

parseFunc

object path reference / ->parseFunc

Processing instructions for the content.

Notice: 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:

parseFunc = < lib.parseFunc_RTE

parseFunc.tags.myTag = TEXT

parseFunc.tags.myTag.value = This will be inserted when &lt;myTag&gt; is found!

HTMLparser

boolean / ->HTMLparser

This object allows you to parse the HTML-content and make all kinds of advanced filterings on the content.

Value must be set and properties are those of ->HTMLparser.

(See adminguide for ->HTMLparser options)

split

->split

prioriCalc

boolean

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 errorchecking and division by zero or other invalid values may generate strange results. Also you use a proper syntax because future modifications to the function used may allow for more operators and features.

Examples:

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

char

int

Content is set to the chr(value).

PHP: $content=chr(intval($conf["char"]);

intval

boolean

PHP function intval(); Returns an integer.

PHP: $content=intval($content);

date

date-conf

The content should be data-type "UNIX-time". Returns the content formatted as a date.

$content=Date($conf["date"], $content);

Example where a timestamp is imported:

.value.field = tstamp

.value.date =

strftime

strftime-conf

Exactly like "date" above. See the PHP-manual (strftime) for the codes, or datatype "strftime-conf".

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

Properties:

.charset  : Can be set to the charset of the output string if you need to convert it to renderCharset. Default is to take the intelligently guessed charset from t3lib_cs.

age

boolean or string

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 four variations:

"xx min" or "xx hrs" or "xx days" or "xx yrs"

The limits between which layout is used are 60 minutes, 24 hours, 365 days,

NOTE:

If you set this property with a non-integer, it's used to format the four units. This is the default value:

" min| hrs| days| yrs"

Set another string if you want to change the units. You may include the "-signs. They are removed anyway.

case

case

Converts case

Uses "renderCharset" for the operation.

bytes

boolean

Will format the input (an integer) as bytes: bytes, kb, mb

If you add a value for the property “labels” you can alter the default suffixes. Labels for bytes, kilo, mega and giga are separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value)

Thus:

bytes.labels = “ | K| M| G”

substring

[p1],  [p2]

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

Uses "renderCharset" for the operation.

removeBadHTML

boolean

Removes "bad" HTML code based on a pattern that filters away HTML that is considered dangerous for XSS bugs.

stripHtml

boolean

Strips all html-tags.

crop

Crops the content to a certain length

Syntax: +/- (chars) = from left / from right | [string] | [boolean: keep whole words]

Examples:  

20 | ...    => max 20 characters. If more, the value will be truncated to first 20 chars and prepended with "..."

-20 | ... => max 20 characters. If more, the value will be truncated to last 20 chars and appended with "..."

20 | ... | 1 => max 20 characters. If more, the value will be truncated to last 20 chars and appended with "...". If the division is in the middle of a word, the remains of that word is removed.

Uses "renderCharset" for the operation.

rawUrlEncode

boolean

Passes the content through rawurlencode()-PHP-function

htmlSpecialChars

boolean

Passes the content through htmlspecialchars()-PHP-function

Additional property “.preserveEntities” will preserve entities so only non-entity chars are affected.

doubleBrTag

string

All double-line-breaks are substituted with this value.

br

boolean

PHP function nl2br(); Converts linebreaks to <br />-tags

brTag

string

All ASCII-codes of "10" (CR) is substituted with value

encapsLines

->encapsLines

Lets you split the content by chr(10) and proces each line independently. Used to format content made with the RTE.

keywords

boolean

splits the content by characters "," ";" and chr(10) (return), trims each value and returns a comma-separated list of the values.

innerWrap

wrap /stdWrap

Wraps the content

innerWrap2

wrap /stdWrap

same as .innerWrap (but watch the order in which they are executed)

fontTag

wrap

addParams

->addParams

Lets you add tag-parameters to the content if the content is a tag!

textStyle

->textStyle

Wraps content in font-tags

tableStyle

->tableStyle

Wraps content with table-tags

filelink

->filelink

Used to make lists of links to files.

preCObject

cObject

cObject prepended the content

postCObject

cObject

cObject appended the content

wrapAlign

align /stdWrap

Wraps content with <div style=text-align:[value];”> | </div> if align is set

typolink

->typolink

Wraps the content with a link-tag

TCAselectItem.

Array of properties

Resolves a comma seperated list of values into the TCA item representation.

.table (string): The Table to look up

.field (string): The field to resolve

.delimiter (string): Delimiter for concatenating multiple elements.

Notice: Currently this works only with TCA fields of type “select” which are not database relations.

spaceBefore

int /stdWrap

Pixels space before. Done with a clear-gif; <img ...><BR>

spaceAfter

int /stdWrap

Pixels space after. Done with a clear-gif; <img ...><BR>

space

space

[spaceBefore]   |   [spaceAfter]

Additional property:

.useDiv = 1

If set, a clear gif is not used by rather a <div> tag with a style-attribute setting the height. (Affects spaceBefore and spaceAfter as well).

wrap

wrap /+.splitChar

.splitChar defines an alternative splitting character (default is “|” - the vertical line)

noTrimWrap

"special" wrap

This wraps the content with the values val1 and val2 in the example below - including surrounding whitespace! - without trimming the values. Note that this kind of wrap requires a "|"  character to begin and end the wrap.

Example:

| val1 | val2 |

wrap2

wrap /+.splitChar

same as .wrap (but watch the order in which they are executed)

dataWrap

The content is parsed for sections of {...} and the content of {...} is of the type getText and substituted with the result of getText.

Example:

This should result in a font-tag where the fontsize is decided by the global variable "size":

<font size="{global : size}"> | </font>

prepend

cObject

cObject prepended to content (before)

append

cObject

cObject appended to content (after)

wrap3

wrap /+.splitChar

same as .wrap (but watch the order in which they are executed)

outerWrap

wrap /stdWrap

Wraps the complete content

insertData

boolean

If set, then the content string is parsed like .dataWrap above.

Example:

Displays the page title:

10 = TEXT

10.value = This is the page title: {page:title}

10.insertData = 1

offsetWrap

x,y

This wraps the input in a table with columns to the left and top that offsets the content by the values of x,y. Based on the cObject OTABLE.

.tableParams / .tdParams /stdWrap

- used to manipulate tableParams/tdParams (default width=99%)  of the offset. Default: See OTABLE.

.stdWrap

- stdWrap properties wrapping the offsetWrap'ed output

postUserFunc

function-name

Calling a PHP-function or method in a class, passing the current content to the function as first parameter and any properties as second parameter. Please see the description of the cObject USER for in-depth information.

Example:

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

page = PAGE

page.typeNum=0

includeLibs.something = media/scripts/example_callfunction.php

page.10 = TEXT

page.10 {

  value = Hello World

  postUserFunc = user_reverseString

  postUserFunc.uppercase = 1

}

page.20 = TEXT

page.20 {

  value = Hello World

  postUserFunc = user_various->reverseString

  postUserFunc.uppercase = 1

  postUserFunc.typolink = 11

}

postUserFuncInt

function-name

Calling a PHP-function or method in a class, passing the current content to the function as first parameter and any properties as second parameter. The result will be rendered non-cached, outside the main page-rendering. Please see the description of the cObject USER_INT and PHP_SCRIPT_INT for in-depth information.

Supplied by Jens Ellerbrock

prefixComment

string

Prefixes content with a 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:

prefixComment = 2 | CONTENT ELEMENT, uid:{field:uid}/{field:CType}

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

(Added in TYPO3 >3.6.0RC1)

editIcons

string

If not empty, then insert an icon linking to the typo3/alt_doc.php with some parameters to build and backend user edit form for certain fields.

The value of this property is a list of fields from a table to edit. It's assumed that the current record of the cObj is the record to be edited.

Syntax: optional tablename : comma list of fieldnames[list of pallette-field names separated by | ]

.beforeLastTag (1,0,-1): If set (1), the icon will be inserted before the last HTML tag in the content. If -1 the icon will be prepended to the content. If zero (0) the icon is appended in the end of the content.

.styleAttribute (string): Adds a style-attribute to the icon image with this value. For instance you can set “position:absolute” if you want a non-destructive insertion of the icon. Notice: For general styling all edit icons has the class “frontEndEditIcons” which can be addressed from the stylesheet of the site.

.iconTitle (string): The title attribute of the image tag.

.iconImg (HTML): Alternative HTML code instead of the default icon shown. Can be used to set another icon for editing (for instance a red dot or otherwise... :-)

Example:

This will insert an edit icon which links to a form where the header and bodytext fields are displayed and made available for editing (provided the user has access!).

editIcons = tt_content : header, bodytext

Or this line that puts the header_align and date field into a “palette” which means they are displayed on a single line below the header field. This saves some space.

editIcons = header[header_align|date], bodytext

editPanel

boolean / editPanel

See cObject EDITPANEL.

debug

boolean

Prints content with HTMLSpecialChars() and <PRE></PRE>: Usefull for debugging which value stdWrap actually ends up with, if you're constructing a website with TypoScript.

Should be used under construction only.

debugFunc

boolean

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

Should be used under construction only.

Set to value “2” the content will be printed in a table - looks nicer.

debugData

boolean

Prints the current data-array, $cObj->data, directly to browser. This is where ".field" gets data from.

Should be used under construction only.

[tsref:->stdWrap]



TYPO3 Core API

TSRef