Building a TYPO3 extension in Extbase/Fluid

Add icons to extension storage folders in page tree

Using multiple extensions with its own records probably leaves you with a quite a list of Storage Folders. Adding custom icons makes you recognize the desired folder faster.

1. Edit your extension’s ext_tables.php

/typo3conf/ext/your_extension/ext_tables.php
(I basically copied this from the news extension by Georg Ringer)

Add the following code:
<?php
if(TYPO3_MODE == 'BE') {
        /*
         * make ext_icon available as page icon in backend page list
         */

        unset($GLOBALS['ICON_TYPES']['extshort']);
        \TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-extshort', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('your_extension').'ext_icon.gif');

        /*
         * make extension selectable in ‘Page Properties => Behaviour => Use as Container’ ext_icon available as page icon in backend page list
         * this will be saved in ‘module’ column of pages table
         * and displayed as a folder icon in backend page list (see SpriteManager::addTcaTypeIcon() above)
         */

        $addExtToModuleSelection = TRUE;
        foreach($GLOBALS['TCA']['pages']['columns']['module']['config']['items'] as $item) {
                if($item[1] === 'extshort') {
                        $addExtToModuleSelection = FALSE;
                        continue;
                }
        }
        if($addExtToModuleSelection) {
                $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array(
                        0 => 'The readable name of your extension',
                        1 => 'extshort',
                        2 => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('your_extension').'ext_icon.gif'
                );
        }
}
?>
        }
}
?>
  • extshort is the short name that will be saved to the ‘module’ column in your pages table. Maximum size is 10 characters (for whatever reason) which won’t be enough for many extension names. So just be creative :)
  • if you want to see another icon than ext_icon.gif, you could save this to /Resources/Public/Icons in your extension folder, the path (twice in the code above) would then be: \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('your_extension').'Resources/Public/Icons/storagefoldericon.gif'

2. Select the icon for your Storage Folder or Page

Edit the Page Properties of the Storage Folder or Page where you store your extension records. Go to Behaviour tab and select the extension under “Use as Container”. Needless to say TYPO3 needs extensive cache flushing before you’ll be able to see the extension in the list, of course. And if, in the page tree, you see a default error icon instead of the folder icon after you saved the properties – just reload again. Should help.