[TYPO3-dev] Standalone View without links
Christoph Kratz
kratz at nterm.de
Sat Jan 24 07:50:36 CET 2015
Hello there,
i have the following problem: I try to render the same output with the standalone view helper, which i have already rendered bevor as normal output. The case is, that i render a menu normally and after frontend changes, i would like to get the menu again, but via ajax.
If i call the standalone view helper, i get the menu content without links. My idea was, that the id's of the pages could fail, but the page titles are there:
$pages = $this->buildMenu(39);
$renderer = $this->getFluidRenderer("ManageWebsite/Menu/Menu.html", "Partials");
$renderer->assign('pages', $pages);
$result = $renderer->render();
.. here's my standalone helper:
public function getFluidRenderer($file = "", $folder="Templates") {
$renderer = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$renderer->setControllerContext($this->controllerContext);
$renderer->setFormat('html');
$path = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName("EXT:test/Resources/Private/".$folder."/");
$renderer->setTemplatePathAndFilename($path . $file);
$renderer->setLayoutRootPath($path);
$renderer->setPartialRootPath($path);
// and return the new Fluid instance
return $renderer;
}
..and here's the menu-builder:
public function buildMenu($uid) {
if ($uid<1) return false;
$this->t3pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$fields = '*';
$sortField = 'sorting';
$addWhere = 'AND deleted = 0 AND nav_hide=0';
$pages = $this->t3pageRepository->getMenu($uid,$fields,$sortField,$addWhere);
foreach($pages as &$page) {
$subPages1 = $this->t3pageRepository->getMenu($page["uid"],$fields,$sortField,$addWhere);
if(count($subPages1)>0){
$page['subpages'] = $subPages1;
}
}
return $pages;
}
.. and the template:
<f:for each="{pages}" as="page">
<f:link.page pageUid="{page.uid}">
{page.title}
</f:link.page>
</f:for>
Hope somebody can help me.
More information about the TYPO3-dev
mailing list