Question

I didn't find a Example how to use a fluid partial in a extbase controller to reuse it for an ajax request/response.

Something like the Tag f:render partial="" but in a controller to return the html in a json response.

Was it helpful?

Solution

I found a solution:

$this->templateView = $this->objectManager->create('Tx_Fluid_View_TemplateView');
$res = t3lib_extMgm::extPath($this->controllerContext->getRequest()->getControllerExtensionKey()) . 'Resources/Private/';
$this->templateView->setLayoutRootPath($res);
$this->templateView->setPartialRootPath($res . 'Partials/');
$this->templateView->setRenderingContext($this->objectManager->create('Tx_Fluid_Core_Rendering_RenderingContext'));
$this->templateView->setControllerContext($this->controllerContext);

$partial = $this->templateView->renderPartial($partialName, Null, $data);

But the only Problem is the setRenderingContext method doesn't set the default RenderingContext correct, i must modify the method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top