Project

General

Profile

Actions

Bug #100995

closed

HMENU with special value "browse" does not generate prev link on second menu item

Added by Tim Horstmann 11 months ago. Updated 10 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
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 #1

Updated by Gerrit Code Review 11 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79258

Actions #2

Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79681

Actions #3

Updated by Anonymous 10 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF