Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3: How do i render tt_content text elements in my own extensions?

Tags:

php

typo3

I'm currently writing a TYPO3 extension which is configured with a list of tt_content UID's. These point to content elements of type "text" and i want to render them by my extension.

Because of TYPO3s special way of transforming the text you enter in the rich text editing when it enters the database, and again transforming it when it is rendered to the frontend, i can not just output the database contents of the bodytext field.

I want to render these texts as they would usually get rendered by TYPO3. How do I do that?

like image 849
arturh Avatar asked Sep 16 '08 11:09

arturh


2 Answers

PHP

That works for me; it renders any content element with the given ID:

function getCE($id)
{
    $conf['tables'] = 'tt_content';
    $conf['source'] = $id;
    $conf['dontCheckPid'] = 1;
    return $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);
}

See http://lists.typo3.org/pipermail/typo3-dev/2007-May/023467.html

This does work for non-cached plugins, too. You will get a string like <!--INT_SCRIPT.0f1c1787dc3f62e40f944b93a2ad6a81-->, but TYPO3 will replace that on the next INT rendering pass with the real content.

Fluid

If you're in a fluid template, the VHS content.render view helper is useful:

<v:content.render contentUids="{0: textelementid}"/>

If your fluidcontent element has a grid itself, you can render the elements with flux' own content.get or content.render view helper:

<f:section name="Configuration>
    ... <flux:grid.column name="teaser"/> ...
</f:section>
<f:section name="Main>
    <flux:content.render area="teaser"/>
<f:section>
like image 124
cweiske Avatar answered Oct 20 '22 00:10

cweiske


I had the same problem a couple of months ago. Now I must say that I am no typo3 developer, so I don't know if this is the right solution.

But I used something like this:

$output .= $this->pi_RTEcssText( $contentFromDb );

in my extension and it works.

like image 33
Jan Hančič Avatar answered Oct 19 '22 22:10

Jan Hančič