Reuse of Extbase Partials for Ajax
I didn't find a Example how to use a fluid partial in a extbase controller to reu开发者_运维问答se 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.
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.
精彩评论