[TYPO3-mvc] Running Fluid within tslib_pibase
Fabien Udriot
fudriot at omic.ch
Sun Mar 21 23:20:54 CET 2010
Thanks Xavier, for sharing your snippets.
Fb.
On 20.03.10 10:43, Xavier Perseguers wrote:
> Hi Fabien,
>
>> I am wondering if there is any pointers about running Fluid in
>> tslib_pibase like: code example, discussion in the ML or something
>> else...
>>
>> I already managed to run Fluid in an external project which had nothing
>> to do with TYPO3 but I remember it was a kind of "do-it-yourself". :D
>
> I did it once and this was basically like that:
>
> /**
> * The main method of the plugin.
> *
> * @param string $content (UNUSED) The plugin content
> * @param array $settings The plugin configuration
> * @return string Content that is displayed on the website
> * @author Xavier Perseguers <xp at sws.ch>
> */
> public function main($content, array $settings) {
> $this->init($settings, array('referenceFields'));
> $this->pi_setPiVarDefaults();
>
> $this->initializeRenderer();
>
> // Stuff to generate content (typically accumulated in $this->content)
>
> return $this->content;
> }
>
>
> /**
> * Initialize the renderer to be used.
> *
> * @return void
> * @author Xavier Perseguers <xp at sws.ch>
> */
> protected function initializeRenderer() {
> $this->renderer = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView');
> $this->renderer->setControllerContext(t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_ControllerContext'));
>
> }
>
> Then something like:
>
> $template = t3lib_extMgm::extPath($this->extKey) .
> 'Resources/Private/Templates/Activities/details.html';
> $this->renderer->setTemplatePathAndFilename($template);
>
> and the
>
> $this->renderer->assign('someVariable', $someValue);
>
> and accumulate your result in $this->content with something like:
>
> $this->content .= $this->renderer->render();
>
> You may of course not accumulate any content and simply return
> $this->renderer->render() in main() but in my case, I had to create
> multiple parts of content, each of them with a dedicated renderer. I
> guess you got the idea and I guess this is what you basically did when
> you "did-it-yourself" ;-)
>
> Cheers
>
More information about the TYPO3-project-typo3v4mvc
mailing list