2016-06-07 72 views
0

直到TYPO3 CMS 6.2我一直在使用中extTables.php下面的代碼提供系統夾圖標:與TYPO3圖標-API系統夾圖標

$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圖標提供給後端?

回答

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' 
    ]; 
} 
+0

很好,謝謝。還有一個關於來源的問題。由於我沒有擴展名,imags位於fileadmin文件夾中,我可以使用'/fileadmin/icons/application_side_list.png'嗎?因爲這似乎不起作用。 Pagetree顯示「/typo3/sysext/core/Resources/Public/Icons/T3Icons/default/default-not-found.svg」 – lufi

+0

據我所知應該是'FILE:fileadmin/icons/...'。 – lorenz

+0

這不起作用。它始終顯示「未找到」圖標。我已經嘗試了很多,這真的很令人沮喪。 – lufi

0

的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/Page/folder_tables.txt: 插入擴展名的表名。

mod.web_list.allowedNewTables = tx_myextkey_tablename1, tx_myextkey_tablename2, tx_myextkey_tablename3