Using stdWrap correctly
The stdWrap function is one of the most powerful and
most widely used of all TypoScript. Most properties actually support std
turning each of them into some kind of Swiss army knife.
std is very rich, having itself a large number of properties. This
chapter is intended to give you a feel for std so that you may get
familiar with it and be ready to explore it in greater depth using the
TypoScript Reference.
Details of stdWrap
Heed the order
The single most important thing to know about std is that all
properties are parsed/executed exactly in the order in which they appear in the
TypoScript Reference, no matter in which order you
have set them in your TypoScript record.
Let's consider this example:
It results in the following:
<strong>Tool: TYPO3</strong>
The case property is executed before the no property.
Hence only "typo3" was changed to uppercase and not the "Tool:" with which it
is wrapped.
Modify the order
There is a way around this ordering restriction. std has a property
called ordered in which several std properties can
be called in numerical order. Thus:
10 = TEXT
10 {
value = typo3
orderedStdWrap {
10.noTrimWrap = |<strong>Tool: |</strong>|
20.case = upper
}
}
results in:
<strong>TOOL: TYPO3</strong>
because we explicitly specified that no should happen before
case.
It should be noted that std itself has a std property,
meaning that it can be called recursively. In most case ordered
will do the job and is much easier to understand making code easier to
maintain.
The data type
While writing TypoScript, it is crucial to know what kind of data type you are handling. It is common to see beginners try to combine functions arbitrarily, until the anticipated result is finally achieved by accident.
The TypoScript reference is very clear about which properties exist and what their data type is, so please refer to that essential resource while writing your TypoScript configuration.
cObject
The std property "cObject" can be
used to replace the content with a TypoScript object. This can be a
COA, a plugin or a text like in this
example: