Skip to content

[FEATURE] Provide PSR-14 event to modify page content preview #1521

@TYPO3IncTeam

Description

@TYPO3IncTeam

ℹ️ View this commit on Github
👥 Authored by Georg Ringer [email protected]
✔️ Merged by Georg Ringer [email protected]

Commit message

[FEATURE] Provide PSR-14 event to modify page content preview

Provide an additional PSR-14 event to modify the generated
page content preview. This is especially useful for integrators
to enrich previews provided by 3rd party extensions.

Resolves: #108462
Releases: main
Change-Id: I49f7be6b51d9c1c0398c5b17b8cf8851055829f0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/92082
Tested-by: Guido Schmechel [email protected]
Reviewed-by: Garvin Hicking [email protected]
Tested-by: Garvin Hicking [email protected]
Tested-by: core-ci [email protected]
Reviewed-by: Guido Schmechel [email protected]
Tested-by: Georg Ringer [email protected]
Reviewed-by: Georg Ringer [email protected]

➕ Added files

14.1/Feature-108462-AddPSR-14EventAfterPageContentPreviewRenderedEvent.rst
..  include:: /Includes.rst.txt

..  _feature-108462-1765368045:

========================================================================
Feature: #108462 - Add PSR-14 Event AfterPageContentPreviewRenderedEvent
========================================================================

See :issue:`108462`

Description
===========

The class :php:`\TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem` is
the central entity to generate various previews of content elements.

Developers can either use the event :php:`\TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent`
to generate a preview or implementing :php:`\TYPO3\CMS\Backend\Preview\PreviewRendererInterface`.

The new PSR-14 event :php:`\TYPO3\CMS\Backend\View\Event\AfterPageContentPreviewRenderedEvent`
can now be used to enrich the output generated by one of those.

Example
=======

An example event listener could look like this:

..  code-block:: php
    :caption: Example event listener class

    namespace MyVendor\MyExtension\EventListener;

    use TYPO3\CMS\Backend\View\Event\AfterPageContentPreviewRenderedEvent;
    use TYPO3\CMS\Core\Attribute\AsEventListener;

    #[AsEventListener('my-extension')]
    final class AfterPageContentPreviewRenderedEventListener
    {
        public function __invoke(AfterPageContentPreviewRenderedEvent $event): void
        {
            $content = 'before<hr />'. $event->getPreviewContent() . '<hr />after';
            $event->setPreviewContent($content);
        }
    }


Impact
======

As integrator it is sometimes handy to enrich the previews of other
content elements and plugins to display additional fields.


..  index:: Backend, PHP-API, ext:backend

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions