Issue Bug Closed

#105316Unhide button in list module for record doesn't show custom overlay-icon

Stephan Lindner s.lindner 10/15/24, 21:07 updated 12/02/25, 14:32

Description

I use the Hook $GLOBALS[‘TYPO3_CONF_VARS’][‘SC_OPTIONS’][\TYPO3\CMS\Core\Imaging\IconFactory::class][‘overrideIconOverlay’][] to set an overlay icon in the list module depending on the value of a field in my record.

<?php

namespace MyNamespace\MyExtension\Hook;

class IconFactoryHook
{
    /**
     * @param string $table
     * @param array $row
     * @param array $status
     * @param string $iconName
     * @return string the new (or given) $iconName
     */
    function postOverlayPriorityLookup($table, array $row, array $status, $iconName) {

        if ($table == "my_table") {
            $record = $this->getRecordByUid('my_table', $row['uid']);
            if ($record['link_type']==1) {
                $statusValue = false;
                foreach ($status as $item) {
                    if ($item === true) {
                        $statusValue = true;
                        break;
                    }
                }
                if (!$statusValue) {
                    $iconName = 'overlay-shortcut';
                }
            }
        }
        return $iconName;
    }

Everything works as expected, when I click on a folder in the page tree. However, if I un-hide a hidden record, the overlay icon for hidden is removed, but my custom icon is not shown. Instead there is no overlay-icon shown. And if I hide a record with my custom overlay icon and unhide it again, the record is un-hidden again, but the hide overlay icon stays at it is.
I would expect, that the hook for an overlay-icon is also called when I un-hide a record so that my overlay-icon is shown as it is shown when I click on the folder in the page tree.

Reviews 3

History 39

  1. Andreas Kienast commented <span data-processor="relativetime" data-value="2024-10-17T14:04:59+00:00" > 10/17/24, 14:04 </span>

    Dummy event listener implementation to test the patch in v13:

    <?php
    
    declare(strict_types=1);
    
    namespace Vendor\Package\EventListener;
    
    use TYPO3\CMS\Core\Attribute\AsEventListener;
    use TYPO3\CMS\Core\Imaging\Event\ModifyRecordOverlayIconIdentifierEvent;
    
    final class ModifyRecordOverlayIconIdentifierEventListener
    {
        #[AsEventListener(identifier: 'icon-modifier', event: ModifyRecordOverlayIconIdentifierEvent::class)]
        public function __invoke(ModifyRecordOverlayIconIdentifierEvent $event) {
            if ($event->getTable() === 'tt_content') {
                if ((int)$event->getRow()['hidden'] === 1) {
                    $event->setOverlayIconIdentifier('overlay-missing');
                }
            }
        }
    }
  2. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2024-11-06T07:00:10+00:00" > 11/06/24, 07:00 </span>

    Applied in changeset commit:c0710cea6d900997edf4ac0fdaa61eabc5de69b7.