i want lazy load several partialtemplates in extbase controller via ajax. therefore found following script render partials doesn't work in context:
private function renderpartial($partialname='', $data = array()){ if($partialname==''){ throw new \typo3\cms\extbase\mvc\exception\requiredargumentmissingexception('the partial name must defined.', 123456789); } $this->templateview = $this->objectmanager->create('typo3\cms\fluid\view\templateview'); $res = \typo3\cms\core\utility\extensionmanagementutility::extpath($this->controllercontext->getrequest()->getcontrollerextensionkey()) . 'resources/private/'; $this->templateview->setlayoutrootpath($res); $this->templateview->setpartialrootpath($res . 'partials/'); $this->templateview->setrenderingcontext($this->objectmanager->create('typo3\cms\fluid\core\rendering\renderingcontext')); $this->templateview->setcontrollercontext($this->controllercontext); return $this->templateview->renderpartial($partialname, null, $data); }
this results in following error: fatal error: __clone method called on non-object in /var/www/html/typo3_src-7.6.0/typo3/sysext/fluid/classes/view/abstracttemplateview.php on line 281
i goolge , found many posts having same problem. can make working. workaround using standaloneview , settemplatepathandfilename() works well. possible use partial without layout/section?
i added debug informations , controller action...
public function searchaction(\pcon\avm\domain\model\demandsearch $demandsearch = null) { //globalsearch if($demandsearch != null) { $searchresult = $this->demandsearchrepository->finddemanded($demandsearch); $this->view->assign('searchresult', $searchresult); } \typo3\cms\extbase\utility\debuggerutility::var_dump($this->controllercontext); $this->templateview = $this->objectmanager->get('typo3\\cms\\fluid\\view\\templateview'); $res = \typo3\cms\core\utility\extensionmanagementutility::extpath($this->controllercontext->getrequest()->getcontrollerextensionkey()) . 'resources/private/'; $this->templateview->setlayoutrootpath($res); $this->templateview->setpartialrootpath($res . 'partials/'); $this->templateview->setrenderingcontext($this->objectmanager->get('typo3\\cms\\fluid\\core\\rendering\\renderingcontext')); $this->templateview->setcontrollercontext($this->controllercontext); \typo3\cms\extbase\utility\debuggerutility::var_dump($this->templateview); return $this->templateview->renderpartial('search/searchform.html', null, array('searchresult'=>$searchresult)); }
i not think ajax problem (definded pagenum). if call controller action without ajax same error appears ...
you can't use renderpartial() oder rendersection() extbase/php in standaloneview. it's missing feature not implemented in typo3 7.6 , below. see task: https://forge.typo3.org/issues/54509
however, can use partials , sections in fluid. assign variables, render template
$this->templateview->render();
and use partials , section in fluid template.
Comments
Post a Comment