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
Updated by Gerrit Code Review almost 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45957
Updated by Gerrit Code Review almost 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45957
Updated by Gerrit Code Review almost 9 years ago
Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/46007
Updated by Georg Ringer almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7983cb75291a30c212e5cde7b1c3e971f22c6f6e.