Implementing a generic footer previewRenderer in TYPO3 >= v12

  Kiến thức lập trình

We have been using the hook tt_content_drawFooter to add additional information in the page layout view in the Backend for some content elements.

Some of the information would always be displayed, for example it shows information about the 18n_parent content element. Some of the information is specific to content elements such as textmedia.

Now, when upgrading to v12, the hook is dropped. There are some replacement events (but not for the footer) and it is possible to override the previewRenderer, e.g. for all types or for specific content types.

The implementation looks straightforward, but I ran into a problem:

  • I can use PageContentPreviewRenderingEvent->setPreviewContent() to override the content (but not the footer)
  • the only way I see to set the footer is by setting the previewRenderer in TCA and then inheriting from the class which was set previously. But for various CE, these will be different classes

For example, this is the default:

general:

$GLOBALS['TCA']['tt_content']['ctrl']['previewRenderer'] = TYPO3CMSBackendPreviewStandardContentPreviewRenderer::class;

textmedia:

$GLOBALS['TCA']['tt_content']['types'][$ctype]['previewRenderer'] = TYPO3CMSFrontendPreviewTextmediaPreviewRenderer;

container content types:

$GLOBALS['TCA']['tt_content']['types'][$ctype]['previewRenderer'] = B13ContainerBackendPreviewContainerPreviewRenderer;

news_pi1:

$GLOBALS['TCA']['tt_content']['types']['news_pi1']['previewRenderer'] = GeorgRingerNewsHooksPluginPreviewRenderer;

So if I set my PreviewRenderer, it would have to be a different class inheriting from a different PreviewRender for each one I want to override.

Also, if an extension is installed, this might override the previewRenderer where it would either override my implemention or I would override its previewRenderer.

It makes something which used to be simple pretty tedious, unflexible and flaky.

What am I missing? Is this not possible or what would be a good solution?

(If overriding the content (not the footer), the problem would not present itself: Extensions could set the previewRenderer for their native CEs and others could use the event. But it seemed a good idea to put this additional information in the footer, while the content is actually intended to show a preview).

Example:

Documentation

  • PageContentPreviewRenderingEvent
  • Changelog v10: Feature: #78450 – Introduce PreviewRenderer pattern
  • Changelog v12: Breaking: #98375 – Removed hooks in Page Module

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT