PHP
这对我来说很有效;它会渲染具有给定ID的任何内容元素:
function getCE($id)
{
$conf['tables'] = 'tt_content';
$conf['source'] = $id;
$conf['dontCheckPid'] = 1;
return $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);
}
看 http://lists.typo3.org/pipermail/typo3-dev/2007-May/023467.html
这对于非缓存插件也有效。你会得到一个字符串,像是 <!--INT_SCRIPT.0f1c1787dc3f62e40f944b93a2ad6a81-->
,但 TYPO3 会在下一次 INT 渲染过程中用真实内容替换它。
页面的所有元素
通过使用 CONTENT:
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
$cObjRend = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$conf = [
'table' => 'tt_content',
'select.' => [
'pidInList' => $myPageUid,
'orderBy' => 'sorting',
'where' => '{#colPos}=0',
],
];
$renderedContent = $cObjRend->cObjGetSingle('CONTENT', $conf);
流体
如果您在一个流体模板中,VHS content.render
视图助手非常有用:
<v:content.render contentUids="{0: textelementid}"/>
如果您的fluidcontent元素本身具有网格,您可以使用flux自己的
content.get
或
content.render
视图助手来渲染元素。
<f:section name="Configuration>
... <flux:grid.column name="teaser"/> ...
</f:section>
<f:section name="Main>
<flux:content.render area="teaser"/>
<f:section>