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:
PageContentPreviewRenderingEvent->setPreviewContent()
to override the content (but not the footer)For example, this is the default:
general:
$GLOBALS['TCA']['tt_content']['ctrl']['previewRenderer'] = \TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer::class;
textmedia:
$GLOBALS['TCA']['tt_content']['types'][$ctype]['previewRenderer'] = \TYPO3\CMS\Frontend\Preview\TextmediaPreviewRenderer;
container content types:
$GLOBALS['TCA']['tt_content']['types'][$ctype]['previewRenderer'] = B13\Container\Backend\Preview\ContainerPreviewRenderer;
news_pi1:
$GLOBALS['TCA']['tt_content']['types']['news_pi1']['previewRenderer'] = GeorgRinger\News\Hooks\PluginPreviewRenderer;
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.
What am I missing? Is this not possible or what would be a good solution?
Example:
Documentation
For context, this is the patch where the previous footer hook was removed:
I would say you have some options:
Option 1:
You could XClass the StandardContentPreviewRenderer. But this would only work for ctypes that directly uses the StandardContentPreviewRenderer. You would then also have to XClass all specific PreviewRenderers. So that's maybe no good solution.
https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Xclasses/Index.html
Option 2:
Implement custom PreviewRenderer for all ctypes you want to manipulate. You could then use a trait to implement your modification. Then you still would need multiple PreviewRenderer, but you could implement your custom code once in the trait.
https://www.php.net/manual/de/language.oop5.traits.php
https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/CodingGuidelines/PhpArchitecture/Traits.html
Option 3:
You could patch your TYPO3 versions StandardContentPreviewRenderer and either implement your code directly in the patch or dispatch your own PSR-14 Event.
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/EventDispatcher/Index.html
https://typo3worx.eu/2017/08/patch-typo3-using-composer/
I think all three solutions comes with some (dis-)advantages. I would tend towards option 2 as I think it is the most stable solution.
EDIT:
I just tested the option Julian Hofmann mentioned above. Yes you could override the footer partial, but then would need to implement an own ViewHelper to manipulate the footer.
This would work, but i would not prefer. But that's just a personal preference.