[TYPO3] Displaying a (Flexible) Content Element from PHP
Helge Preuss
scout at hyperspace-travel.de
Sun May 6 23:25:07 CEST 2007
>>> in an extension I am writing I need to display a Content Element,
>>> preferably a Flexible Content Element, from PHP. I haven't found a
>>> function to do this in the API documentation or on Google, but I am sure
>>> there must exist one.
>>>
>>> Can you help me out, please?
>>>
>>>
>> http://typo3.org/documentation/document-library/extension-manuals/templavoila/1.3.0/view/1/6/
>>
>> and check the mini news code for reference and hints.
>>
>
> Digging through the docs and the Templavoila code, I found the following
> function:
>
> /**
> * Common function for rendering of the Flexible Content / Page
> Templates.
> * For Page Templates the input row may be manipulated to contain
> the proper reference to a data structure (pages can have those inherited
> which content elements cannot).
> *
> * @param array Current data record, either a tt_content
> element or page record.
> * @param string Table name, either "pages" or "tt_content".
> * @return string HTML output.
> */
> function renderElement($row,$table) {
> // ...
> }
>
> I assume this is the one I have to use to render a Flexible CE. But when
> I try to use it, I get this error:
>
> Fatal error: Call to a member function editIcons() on a non-object in
> /var/www/onlinetaz/typo3_src-4.0.5/typo3/sysext/cms/tslib/class.tslib_pibase.php
> on line 910
>
> I have tried to access the function in this way:
>
> $FCE_Renderer = t3lib_div::makeInstance('tx_templavoila_pi1');
> return $FCE_Renderer->renderElement($ce, 'tt_content');
>
> What am I doing wrong?
>
Found it: I must call
$FCE_Renderer->cObj = t3lib_div::makeInstance('tslib_cObj');
to assign a cObj to the tx_templavoila_pi1 instance.
More information about the TYPO3-english
mailing list