The TEXT cObject

Typoscript's TEXT cObject is probably the single most widely used of all the cObjects. Like its sibling, the HTML cObject, the TEXT cObject can be used to output static text or html, but is very frequently used as the vehicle for stdWrap's content-supplying functions.

In fact, the TEXT cObject is so similar to the HTML cObject that it's probably easiest to explain how it differs from the HTML cObject.

Example 1: Static Text

Like HTML, the TEXT cObject has only one property–"value"–but unlike HTML, that property has the data type "value." This data type is not explicitly listed in the TSref, but it is effectively identical to the "HTML-code" data type. In other words, the TEXT cObject's value property just accepts a string.

But the TEXT object can also use stdWrap to wrap, transform or supply content the same way the HTML cObject can. The difference–the critical difference–is that the stdWrap properties and functions are applied directly to the "root" of the object. As the TSref notes, "this is non-standard."

In the following example, note that the value property is supplied with a string, but that we use stdWrap's wrap and case functions are directly inside the object (compare to the equivalent example using the HTML cObject):

  1. lib.tsref.cObject.TEXT.1 = TEXT
  2. lib.tsref.cObject.TEXT.1{
  3.   value = Hello world!
  4.   case = upper
  5.   wrap = <strong>|</strong>
  6. }

As with the HTML cObject, this produces the following markup (shown in HTML and rendered versions):

HTML output
<strong>HELLO WORLD!</strong>
TS output
HELLO WORLD!

Example 2: Supplying Content with stdWrap

To complete our illustration of how TEXT differs from HTML in Typoscript, we reproduce Example 3 from the HTML cObject page, altered to use a TEXT cObject–again, note that the stdWrap functions wrap and case are applied to the object directly rather than to the value property:

  1. lib.tsref.cObject.TEXT.2 = TEXT
  2. lib.tsref.cObject.TEXT.2{
  3.   data = page:subtitle
  4.   case = upper
  5.   wrap = <strong>|</strong>
  6. }
HTML output
<strong>TYPOSCRIPT'S TEXT COBJECT</strong>
TS output
TYPOSCRIPT'S TEXT COBJECT

Comments

No comments

Add comment

*
*
* required field

TEXT cObject in the TSref

www.typo3apprentice.com
A Bedlam Hotel project © 2007—2010

Report a problem with this page

Bookmark and Share