Render cObj RECORDS fully or slimmed
Monday, May 24th, 2010Short 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:
-
lib.addressline = RECORDS
-
lib.addressline.source = 47
-
lib.addressline.tables = tt_content
It outputs a tt_content record with uid 47 like this:
-
<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
-
lib.addressline = RECORDS
-
lib.addressline.source = 47
-
lib.addressline.tables = tt_content
-
lib.addressline.conf.tt_content = TEXT
-
lib.addressline.conf.tt_content.field = bodytext
Which renders this instead:
-
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….