TSref/stdWrap

From TYPO3Wiki

Jump to: navigation, search
TypoScript Referenz - stdWrap
Translations info
An english page for every translation.
All pagenames in english.

  en       de   nl   fr   ja   zh  

This page is document in progress. TypoScript

Contents

stdWrap

the official tsref: http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/5/1/

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.

Get Data:

setContentToCurrent

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

#Datatype
boolean

setCurrent

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

#Datatype
string /stdWrap

lang

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.

#Datatype
Array of language keys


#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

#Datatype
getText

field

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

$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.

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

current

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

#Datatype
boolean

cObject

Loads content from a content-object

#Datatype
cObject

numRows

Returns the number of rows resulting from the select

#Datatype
->numRows

filelist

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

#Datatype
dir /stdWrap


preUserFunc

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

#Datatype
function-name

Override / Conditions:

override

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

#Datatype
string /stdWrap

preIfEmptyListNum

(as "listNum" below)

#Datatype
(as "listNum" below)

ifEmpty

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

#Datatype
string /stdWrap

ifBlank

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

#Datatype
string /stdWrap

listNum

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

#Datatype
int
+calc
+"last"


trim

PHP-function trim(); Removes whitespace around value

stdWrap

Recursive call to stdWrap function

#Datatype
->stdWrap

required

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.

#Datatype
boolean

if

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

#Datatype
if

fieldRequired

value in this field MUST be set

#Datatype
fieldname

Parse Data:

csConv

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

# Datatype
string

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.

#Datatype
object path reference / ->parseFunc
#Example:
parseFunc = < lib.parseFunc_RTE
parseFunc.tags.myTag = TEXT
parseFunc.tags.myTag.value = This will be inserted when <myTag> is found!

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)


#Datatype
boolean / ->HTMLparser	

split

#Datatype
->split

prioriCalc

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.

#Datatype
boolean
#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

Content is set to the chr(value).

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

#Datatype
int

intval

PHP function intval(); Returns an integer.

PHP: $content=intval($content);

#Datatype
boolean

date

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

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

#Datatype
date-conf
#Example where a timestamp is imported:
.value.field = tstamp
.value.date =

strftime

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.

#Datatype
strftime-conf


age

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.

#Datatype
boolean or string


case

case


Converts case

Uses "renderCharset" for the operation.

#Datatype
lower
upper
#Example
page.40 = HTML
page.40.value = Hello World.
page.40.value.case = lower

bytes

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”

#Datatype
boolean 

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

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

#Datatype
boolean

stripHtml

Strips all html-tags.

#Datatype
boolean


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

Passes the content through rawurlencode()-PHP-function

#Datatype
boolean


htmlSpecialChars

Passes the content through htmlspecialchars()-PHP-function

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

#Datatype
boolean


doubleBrTag

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

#Datatype
string


br

PHP function nl2br(); Converts linebreaks to
-tags

#Datatype
boolean

brTag

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

#Datatype
string


encapsLines

->encapsLines


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


keywords

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

#Datatype
boolean

innerWrap

Wraps the content

#Datatype
wrap /stdWrap


innerWrap2

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

#Datatype
wrap /stdWrap


fontTag

#Datatype
wrap


addParams

#Datatype
->addParams

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


textStyle

#Datatype
->textStyle


Wraps content in font-tags


tableStyle

#Datatype
->tableStyle


Wraps content with table-tags


filelink

#Datatype
filelink

Used to make lists of links to files.


preCObject

cObject prepended the content

#Datatype
cObject


postCObject

cObject appended the content

#Datatype
cObject


wrapAlign

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

#Datatype
align /stdWrap

typolink

#Datatype
typolink
#Example
# TEXT has an stdWrap property - you can use it to set an link around text
10 = TEXT
10.value = link to page 42
10.typolink.parameter = 42
# The HTML Object has the stdWrap property on value - not on itself as TEXT has
20 = HTML
20.value = link to page 43
20.value.typolink.parameter = 43

Wraps the content with a link-tag


TCAselectItem.

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.

#Datatype
Array of properties


spaceBefore

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

#Datatype
int /stdWrap


spaceAfter

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

#Datatype
int /stdWrap


space

[spaceBefore] | [spaceAfter]

Additional property:

.useDiv = 1

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

wrap

#Datatype
wrap /+.splitChar


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


noTrimWrap

#Datatype
"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:
noTrimWrap = | text with spaces around       | the spaces will not be trimmed! |
wrap =       spaces around an normal | wrap will be trimmed


wrap2

#Datatype
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

#Datatype
cObject


cObject prepended to content (before)


append

#Datatype
cObject


cObject appended to content (after)


wrap3

#Datatype
wrap /+.splitChar


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


outerWrap

#Datatype
wrap /stdWrap


Wraps the complete content


insertData

#Datatype
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

#datatype
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

#Datatype
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

#Datatype
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

#Datatype
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

#Datatype
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

#Datatype
boolean / editPanel


See cObject EDITPANEL.


debug

#Datatype
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

#Datatype
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

#Datatype
boolean


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

Should be used under construction only.

page.20 = TEXT
page.20 {
 value = Hello World
 postUserFunc = user_various->reverseString
 postUserFunc.uppercase = 1
 postUserFunc.typolink = 11
}
Personal tools