0
votes

Till TYPO3 CMS 6.2 i've been using the following code in extTables.php to provide sysfolder icons:

$TCA['pages']['columns']['module']['config']['items'][] = array('Templates', 'templates', '/fileadmin/icons/application_side_list.png');
\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-templates', '/fileadmin/icons/application_side_list.png');

As since 7.6 the code is obsolete and icons are provided by the Icon-API. Am I right? So my question is, if it's still possible to provide sysfolder icons to the backend using BitmapIconProvider, SvgIconProvider or the FontawesomeIconProvider?

2

2 Answers

1
votes

Yes, this should work using the IconRegistry core class:

ext_localconf.php:

if (TYPO3_MODE === 'BE') {
    /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
    $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
    $iconRegistry->registerIcon(
        'apps-pagetree-folder-contains-templates',
        \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
        ['source' => 'EXT:myext/Resources/Public/Icons/application_side_list.png']
    );
}

ext_tables.php:

if (TYPO3_MODE === 'BE') {
    $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [
        0 => 'Templates',
        1 => 'templates',
        2 => 'apps-pagetree-folder-contains-templates'
    ];
}
1
votes

The TYPO3 extension must be modified to fit the needs of TYPO3 7.5 and higher. Replace myextkey by the extension key of your extension.

ext_localconf.php:

if (TYPO3_MODE == 'BE') {
    $pageType = 'myext10'; // a maximum of 10 characters

    $icons = array(
        'apps-pagetree-folder-contains-' . $pageType => 'apps-pagetree-folder-contains-myextkey.svg'
    );
    /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
    $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
    foreach ($icons as $identifier => $filename) {
        $iconRegistry->registerIcon(
            $identifier,
            $iconRegistry->detectIconProvider($filename),
            array('source' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/' . $filename)
        );
    }
}

Configuration/TCA/Overrides/pages.php:

<?php

if (!defined ('TYPO3_MODE')) {
    die ('Access denied.');
}

// add folder icon
$pageType = 'myext10'; // a maximum of 10 characters
$iconReference = 'apps-pagetree-folder-contains-' . $pageType;

$addToModuleSelection = TRUE;
foreach ($GLOBALS['TCA']['pages']['columns']['module']['config']['items'] as $item) {
    if ($item['1'] == $pageType) {
        $addToModuleSelection = false;
        break;
    }
}

if ($addToModuleSelection) {
    $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-' . $pageType] = $iconReference;

    $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array(
        0 => 'LLL:EXT:myextkey/locallang.xml:pageModule.plugin',
        1 => $pageType,
        2 => $iconReference
    );
}

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
    $pageType,
    'Configuration/TSconfig/Page/folder_tables.txt',
    'EXT:myextkey :: Restrict pages to myextkey records'
);

locallang.xml:

<label index="pageModule.plugin">My Extension: Table names of my extension</label>

Resources/Public/Icons/apps-pagetree-folder-contains-myextkey.svg: vector graphic image file for your extension tables

see https://github.com/TYPO3/TYPO3.Icons for working example SVG icons.

Configuration/TSconfig/Page/folder_tables.txt: Insert the table names of your extension.

mod.web_list.allowedNewTables = tx_myextkey_tablename1, tx_myextkey_tablename2, tx_myextkey_tablename3