带有TYPO3 Icon-API的SysFolder图标

时间:2016-06-07 14:37:38

标签: typo3 typo3-7.6.x

直到TYPO3 CMS 6.2我一直在使用extTables.php中的以下代码来提供sysfolder图标:

$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');

自7.6以来,代码已过时,图标由Icon-API提供。我对吗?所以我的问题是,如果仍然可以使用BitmapIconProvider,SvgIconProvider或FontawesomeIconProvider向后端提供sysfolder图标吗?

2 个答案:

答案 0 :(得分:1)

是的,这应该可以使用IconRegistry核心类:

<强> 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 :(得分:1)

必须修改TYPO3扩展名以满足TYPO3 7.5及更高版本的需要。用扩展程序的扩展名替换myextkey。

<强> 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)
        );
    }
}

<强>配置/ TCA /覆盖/ 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>

<强>资源/公共/图标/应用-pagetree-文件夹包含-myextkey.svg: 扩展表的矢量图形图像文件

请参阅https://github.com/TYPO3/TYPO3.Icons了解SVG图标的工作示例。

<强>配置/ TSconfig /页/ folder_tables.txt: 插入扩展程序的表名。

mod.web_list.allowedNewTables = tx_myextkey_tablename1, tx_myextkey_tablename2, tx_myextkey_tablename3