Issue Bug Closed

#109404Hook ['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] is not "usable"

Xavier Perseguers 03/27/26, 13:49 updated 04/21/26, 11:30

Description

Since I’m about to implement it a second time, I think it’s wise to make it clear the hook is actually not “usable” since all class fields have been marked as protected/private, long ago.

  • Hook: [‘SC_OPTIONS’][‘typo3/show_item.php’][‘typeRendering’]
  • Hook is located in: \TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController

Problems with passed reference to $pObj

  • Protected field $table => must be either public or (better) accessible with a getter
  • Protected field $row => must be either public or (better) accessible with a getter
  • Protected method getPageTitle => should be public, same for all other similar methods used by the Core to prepare the page as the hook take over but should not have to reinvent the wheel, it should be possible to extend

In addition, I would suggest to pass the view $view to the hook, otherwise:

1. The page title cannot be set
2. Other variables cannot be assigned (not in use but certainly useful for a hook, generally-speaking).

Reviews 2

History 57

  1. Garvin Hicking commented and changed category status New Needs Feedback TYPO3 Version 12 13 <span data-processor="relativetime" data-value="2026-03-27T16:57:49+00:00" > 03/27/26, 16:57 </span>

    I’m raising this to v13 because due to end of community support of v12 it is very unlikely it will be addressed here.

    I guess a meta method like getContext() or so would be good, that could wrapp all the needed objects.

    Would you like to work out a patch for this against v13?

  2. Xavier Perseguers commented <span data-processor="relativetime" data-value="2026-03-30T14:30:41+00:00" > 03/30/26, 14:30 </span>

    What about the view? If we have a getContext() method, it will logically return an array of the various fields I mentioned (->table and ->row), possibly the result of ->getPageTitle() as well, but $view is a local variable where the hook is being called, so if we want to pass it along, we will have to promote it as a class field/property…

  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2026-03-30T17:47:40+00:00" > 03/30/26, 17:47 </span>

    I thought about something like this:

            // render type by user func
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] ?? [] as $className) {
                $typeRenderObj = GeneralUtility::makeInstance($className);
                if (method_exists($typeRenderObj, 'setContext')) {
                    // User func needs to implement:
                    //   public function setContext(string $type, array $row, ?string $table, ?File $fileObject, ?Folder $folderObject, ViewInterface $view): void
                    // a userfunc can then store this context and utilize it in its `$this->render()` method.
                    $typeRenderObj->setContext(
                        $this->type,
                        $this->row,
                        $this->table,
                        $this->fileObject,
                        $this->folderObject,
                        $view, 
                    );
                }
                if (method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
                    if ($typeRenderObj->isValid($this->type, $this)) {
                        $view->assign('hookContent', $typeRenderObj->render($this->type, $this));
                        return $view->renderResponse('ContentElement/ElementInformation');
                    }
                }
            }

    This would require implementing a new method inside your own userfunc though. So the more I think about it, creating simple getters for the methods might be more maintainable and less overkill.

    (Same goes for making getPageTitle public, I understand that).

    If you could go ahead to create a patch with the public getters and pageTitle method, I’d vote for it….

  4. Gerrit Code Review pushed patch set 1 for main to change 93489 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2026-03-31T11:27:15+00:00" > 03/31/26, 11:27 </span>

  5. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-31T19:15:10+00:00" > 03/31/26, 19:15 </span>

    Applied in changeset commit:309bbf5e7a1ed65a1484ca3545e4e0b7a55ceffd.