Render cObj RECORDS fully or slimmed

Short share of TypoScript know-how..

TYPO3 comes with a handfull different cObjects, such as TEXT, IMAGE etc.. (see the tsref) and then there are the more general cObjects for content rendering; CONTENT and RECORDS. The CONTENTS object focuses on a more widely rendering process, where you find your data with a select property, and a renderObj output.. ..then there is the little bit simpler variant RECORDS that allows you to find and output records from one or more tables in a bit more raw way thant CONTENT allows you to.. anyway.. what I wanted to share today was this difference when outputing a RECORDS object..

Take this TypoScript:

  1. lib.addressline = RECORDS
  2. lib.addressline.source = 47
  3. lib.addressline.tables = tt_content

It outputs a tt_content record with uid 47 like this:

  1. <div id="c47"><p>My content with uid 47</p></div>

Quite often you might want it a bit more trimmed.. (especially when you map it with typoscript object path in templavoila into a predifend position in a template). Then you can do like this

  1. lib.addressline = RECORDS
  2. lib.addressline.source = 47
  3. lib.addressline.tables = tt_content
  4. lib.addressline.conf.tt_content = TEXT
  5. lib.addressline.conf.tt_content.field = bodytext

Which renders this instead:

  1. My content with uid 47

The basic thing is – define what you want in your output, and ignore the rest. The same could be done with a logotype image or similar (mapping an image content outputs a lot of extra wrappings by default..)

Another small notice; If you map a ts object from templavoila and get HTML output as text, then edit DS/TO and uncheck “as content through htmlSpecialChars (HSC)” for that field….

Leave a Reply