2011-06-16 34 views
2

我沒有找到一個示例如何在extbase控制器中使用流體部分來重用它的ajax請求/響應。重新使用Extbase部分的Ajax

類似於標籤f:render partial =「」但在控制器中返回json響應中的html。

回答

1

我找到了一個解決方案:

$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); 

但唯一的問題是setRenderingContext方法不設置默認RenderingContext正確的,我必須修改方法。