Review 13.4 Merged

87121[FEATURE] Allow modifying fetched page content

Oli Bartsch CR +2 V +2 Normal +143 −13 updated 11/20/24, 18:55

Commit message

With #103894, the `PageContentFetchingProcessor` was introduced.
It allows to easily fetch and provide page content based on
the selected page layout in fluid templates.

While this makes the configuration effort a lot easier
for the most common use cases, it fails to provide
any possibility for custom adjustments.

For example, EXT:content_block needs to provide
an additional condition to the select configuration,
to hide "inline content elements" [2].

Since this is not directly possible when using the
`PageContentFetchingProcessor` [1], the new PSR-14
AfterContentHasBeenFetchedEvent is introduced as
an exceptional feature. The event therefore allows
to modify the fetched page content.

Therefore, instead of using user functions
to manipulate SQL statements, e.g.

page.20 = CONTENT
page.20 {
    table = tt_content
    select {
        orderBy = sorting
        where = colPos=0
        where.postUserFunc = TYPO3\CMS\ContentBlocks\UserFunction\ContentWhere->extend
    }
}

one can now use the event to post
process the fetched content:

public function __invoke(AfterContentHasBeenFetchedEvent $event): void
{
    foreach ($event->groupedContent['main']['records'] as $key => $record) {
        if ($record->has('parent_field_name') && (int)($record->get('parent_field_name') ?? 0) > 0) {
            unset($event->groupedContent['main']['records'][$key]);
        }
    }
}

[1] https://github.com/FriendsOfTYPO3/content-blocks/issues/273
[2] https://docs.typo3.org/p/friendsoftypo3/content-blocks/main/en-us/API/NestedContentElements/Index.html#preventing-output-in-frontend

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
  • Verified V +2 Done
    • Oli Bartsch +2
    • core-ci +1 CI

Issues 2

Files 5

Review log 34

  1. Oli Bartsch commented on patch set 1 11/20/24, 17:46

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 11/20/24, 17:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69835

  3. Oli Bartsch voted on patch set 1 CR +2 V +2 11/20/24, 18:55

  4. Oli Bartsch merged patch set 2 11/20/24, 18:55