Login / Status
developer.Resource
Home . Documentation . Document Library . Core Documentation
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

Chapter 4. stdWrap

4.1. The concept, stdWrap

(Pronounced "Standard wrap")

stdWrap is a wizard in many cases. It's the grown-up wrapping-concept.

To give a very educating example, I'll introduce you to the TEXT and HTML content objects (cObjects). Refering to the TSref:

The "TEXT" cObject seems to have a .value property. Datatype is "value" which - according to the list of datatypes - is something, you decide on your own. (Had the datatype been "HTML-color", then you had to specify an HTML-color as value, like "red" or "#FF0000").

The "HTML" object also has a .value property. This is defined to be "HTML" - which practically is the same as the TEXT-object. It's just a string-value.

The difference of the two cObjects seems to be the way stdWrap is implemented. But first take a look at the description of the stdWrap object in the TSref.

This is some of the properties of stdWrap. Basically the stdWrap-object (also called "function" sometimes) does (primarily at least) is processing content in some way. One property which has an immediate noticeable function is the .case property of the stdWrap object. "case" is not listed in this example image, but look it up yourself in the TSref (it's about time you open that "book")

The .case property is able to convert the case of the input. Now, according to the TEXT and HTML cObject description, this is how it works:

The TEXT cObject:

The stdWrap properties are on the TEXT-object itself. This means that

page = PAGE
page.typeNum=0
page.10 = TEXT
page.10.value = Hello world
page.10.case = upper

... outputs "HELLO WORLD"

The HTML cObject:

The stdWrap properties are on the .value property of the HTML-object. This means that

page = PAGE
page.typeNum=0
page.10 = HTML
page.10.value = Hello world
page.10.value.case = upper

... outputs "HELLO WORLD"

(Comment: The stdWrap properties are a bit inconsistently implemented on the TEXT-object because the .value property is "mixed" with the stdWrap properties. Luckily the "value" property is not defined for the stdWrap object so in real life it doesn't matter. But anyway, it's 'bad' design - maybe even confusing - of the cObject "TEXT". This situation is also the case of a few other objects like CARRAY)

While you're here...

Try to view the source of the page you just created. Notice that Typo3 by default defines an HTML header and bodysection for you! By setting properties for the PAGE-object you can modify the content of these section though. Even disable them.

General implementation

stdWrap is very powerful and sort of compensates for the fact that TypoScript really cannot be programmed to do any control structures (except from the "conditions") because you can make stdWrap compare values and based on the result choose to return another value and so on. But generally that's taking it too far.

Normally you'll see stdWrap-properties implemented like you've seen for the .value property of the HTML cObject. Example you acn refer to in the TSref is such as .... well nearly half the property-values you can define including many of the properties for stdWrap itself!'



TYPO3 Core API

TSRef

TYPO3 Coding Guidelines