简体   繁体   English

如何在 TYPO3 扩展中为内容元素或插件设置图标

[英]How to setup icons for content elements or plugins in a TYPO3 extension

How are icons configured for content elements and plugins?如何为内容元素和插件配置图标? Is there a shortcut to make it possible to configure it only once and not in 3 places?是否有一个快捷方式可以只配置一次而不是三个地方?

AFAIK, there are 3 places to configure icons when creating new custom content elements & plugins in the TYPO3 backend : AFAIK,在TYPO3 后端创建新的自定义内容元素和插件时,有 3 个地方可以配置图标

  1. New Content Element wizard新建内容元素向导
  2. What is visible in the CType / list_type select list when you edit the content element (CE)编辑内容元素时 CType / list_type select 列表中可见的内容 (CE)

在此处输入图像描述

  1. What is visible in the Page Layout view页面布局视图中可见的内容

在此处输入图像描述

First, register an icon identifier to reference your icon, see official TYPO3 documentation: Icon API > Registration .首先,注册一个图标标识符来引用您的图标,请参阅官方 TYPO3 文档: 图标 API > Registration

You can register for example SVG icons or Font Awesome icons.您可以注册例如 SVG 图标或 Font Awesome 图标。


Next, make sure the icon is configured correctly in these 3 places:接下来,确保在这 3 个地方正确配置了图标:

1. New Content Element (CE) wizard 1. 新内容元素 (CE) 向导

Is configured in Page TSconfig在页面 TSconfig 中配置

eg (use the previously registered icon identifier)例如(使用之前注册的图标标识符)

mod.wizards.newContentElement.wizardItems.common.show:=addToList(extkey_plugin)
mod.wizards.newContentElement.wizardItems.common.elements.extkey_plugin {
  iconIdentifier = my-icon
  # ...
}

TYPO3 documentation: Add content elements to the Content Element Wizard TYPO3 文档: 将内容元素添加到内容元素向导


2. CType / list_type select list: 2. CType / list_type select 列表:

For Extbase plugins this is configured via registerPlugin (parameter 4)对于 Extbase 插件,这是通过 registerPlugin 配置的(参数 4)

Configuration/TCA/Overrides/tt_content.php : Configuration/TCA/Overrides/tt_content.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'ExtkeyInCamelCase', 
    'PluginIdentifier', 
    'plugin title', 
    // icon 
    'my-icon');

TYPO3 documentation: Extbase Plugin registration TYPO3 文档: Extbase 插件注册

For content elements, this can be configured via TCA:对于内容元素,可以通过 TCA 进行配置:

Configuration/TCA/Overrides/tt_content.php : Configuration/TCA/Overrides/tt_content.php

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
    'Title',
    // plugin signature: extkey_identifier
    'myext_plugin',
    // icon identifier
    'my-icon',

TYPO3 documentation: Register the content element TYPO3 文档: 注册内容元素


3. In the Page Layout view: 3. 在页面布局视图中:

For content elements, you can set it in TCA:对于内容元素,您可以在 TCA 中进行设置:

Configuration/TCA/Overrides/tt_content.php : Configuration/TCA/Overrides/tt_content.php

$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$pluginname] = 'my-icon';

TYPO3 documentation: typeicon_classes TYPO3 文档: typeicon_classes

AFAIK it is not possible to change this for plugins, the default plugin icon is used. AFAIK 无法为插件更改此设置,使用默认插件图标。 But you can add an icon within the plugin content to be displayed in the Page Layout view with a hook, eg look in news or calendarize extension for examples, add your function in但是您可以在插件内容中添加一个图标,以便使用钩子在页面布局视图中显示,例如查看新闻或日历扩展例如,将您的 function 添加到

ext_localconf.php : ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['extkey_plugin']['extkey'] =
  \Vendor\Extkey\Hooks\PageLayoutView::class . '->getExtensionSummary';

custom:风俗:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM