Bug #72543
closedDirectoryViewHelper levelAs not working in fluid_styled_content
100%
Description
I added a menu via <ce:menu.directory pageUids="{pageUids}" as="pages" levelAs="level"> and the generation of the menu works fine, but the variable "level" is empty and it seems that the view helper does not send the right register variable to the template.
The view Helper does this:
if (!empty($levelAs)) {
$variables[$levelAs] = $typoScriptFrontendController->register['ceMenuLevel'];
}
but the register that is used to count the level is in:
$typoScriptFrontendController->register['ceMenuLevel_directory']
So the DirectoryViewHelper render-function needs to look something like this:
@
public function render()
{
$typoScriptFrontendController = $this->getTypoScriptFrontendController();
$as = $this->arguments['as'];
$pageUids = (array)$this->arguments['pageUids'];
$entryLevel = $this->arguments['entryLevel'];
$levelAs = $this->arguments['levelAs'];
$maximumLevel = $this->arguments['maximumLevel'];
$includeNotInMenu = (bool)$this->arguments['includeNotInMenu'];
$includeMenuSeparator = (bool)$this->arguments['includeMenuSeparator'];
$pageUids = $this->getPageUids($pageUids, $entryLevel);
$pages = $typoScriptFrontendController->sys_page->getMenu(
$pageUids,
'*',
'sorting',
$this->getPageConstraints($includeNotInMenu, $includeMenuSeparator)
);
$output = '';
if (!empty($pages)) {
if (!$typoScriptFrontendController->register['ceMenuLevel_directory']) {
$typoScriptFrontendController->register['ceMenuLevel_directory'] = 1;
$typoScriptFrontendController->register['ceMenuMaximumLevel_directory'] = $maximumLevel;
} else {
$typoScriptFrontendController->register['ceMenuLevel_directory']++;
}
if ($typoScriptFrontendController->register['ceMenuLevel_directory'] > $typoScriptFrontendController->register['ceMenuMaximumLevel_directory']) {
// count down before returning or the counter register will be messed up
$typoScriptFrontendController->register['ceMenuLevel_directory']--;
return '';
}
$variables = array(
$as => $pages
);
if (!empty($levelAs)) {
// register right variable for template usage
$variables[$levelAs] = $typoScriptFrontendController->register['ceMenuLevel_directory'];
}
$output = $this->renderChildrenWithVariables($variables);
$typoScriptFrontendController->register['ceMenuLevel_directory']--;
if ($typoScriptFrontendController->register['ceMenuLevel_directory'] <= 0) {
unset($typoScriptFrontendController->register['ceMenuLevel_directory']);
unset($typoScriptFrontendController->register['ceMenuMaximumLevel_directory']);
}
}
return $output;
}
@
TYPO3 version is 7.6.2