Actions
Bug #100995
closedHMENU with special value "browse" does not generate prev link on second menu item
Start date:
2023-06-12
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
hmenu browse prev menu
Complexity:
Is Regression:
Sprint Focus:
Description
With the following typoscript snippet, a link to the previous page should be generated.
Typoscript
10 = FLUIDTEMPLATE
10 {
file = EXT:site_package/Resources/Private/Templates/Page/MyTemplate.html
dataProcessing {
10 {
special = browse
special {
items = prev
}
as = prevLink
}
}
Fluid
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="{prevLink}">
{prevLink.0.title}
</f:if>
</html>
This works as expected except for the second page of the same level.
The following page tree with uids is given as example:- Page 1
- Page 2
- Page 3
- Page 4
- Page 5
- Page 6
On Page 2 and 4 (the second page on each level), the previous link is not generated.
The reason is a bug in \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject.
The previous item $recArr['prev'] is determined with a check against the array key ($lastKey, numerical indices). For the second item on a level (key = 1) the check for the previous item (key = 0) fails, because 0 = false and therefore no previous link is determined.
$lastKey = 0;
$nextActive = 0;
foreach ($prevnext_menu as $k_b => $v_b) {
if ($nextActive) {
$recArr['next'] = $v_b;
$nextActive = 0;
}
if ($v_b['uid'] == $specialValue) {
if ($lastKey) {
$recArr['prev'] = $prevnext_menu[$lastKey];
}
$nextActive = 1;
}
$lastKey = $k_b;
}
Actions