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

痴心易碎 提交于 2019-12-06 00:23:30

问题


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?


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/71223/typo3-how-do-i-render-tt-content-text-elements-in-my-own-extensions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!