Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 类型3-6.2 Extbase自定义内容类型->;无效值_Typo3_Extbase_Typo3 6.2.x - Fatal编程技术网

Typo3 类型3-6.2 Extbase自定义内容类型->;无效值

Typo3 类型3-6.2 Extbase自定义内容类型->;无效值,typo3,extbase,typo3-6.2.x,Typo3,Extbase,Typo3 6.2.x,我为自定义内容元素做了一个extbase扩展。因为这是我的第一个扩展,我从一个简单的“hello\u world\u ce”开始。这是我的文件: ext_tables.php <?php $TCA['tt_content']['types']['hello_world_ce']['showitem'] = '--palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element

我为自定义内容元素做了一个extbase扩展。因为这是我的第一个扩展,我从一个简单的“hello\u world\u ce”开始。这是我的文件:

ext_tables.php

<?php
$TCA['tt_content']['types']['hello_world_ce']['showitem'] = '--palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.general;general, --palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.header;header';
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:'.$_EXTKEY.'/Configuration/TypoScript/ModWizards.ts">');
$backupCTypeItems = $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'];
$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] = array(
    array(
        'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_tab_header',
        '--div--'
    ),
    array(
        'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world',
        'hello_world_ce',
        'i/tt_content_header.gif'
    )
);
foreach($backupCTypeItems as $key => $value){
    $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = $value;
}
在TYPO3后端,我看到我的内容元素,可以将其添加到页面中,但内容类型的下拉菜单显示无效值(“hello\u world\u ce”)

我错过了什么

编辑:我找到了丢失的部分。我需要将我的内容类型添加到CType数组中

ext_tables.php

<?php
$TCA['tt_content']['types']['hello_world_ce']['showitem'] = '--palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.general;general, --palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.header;header';
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:'.$_EXTKEY.'/Configuration/TypoScript/ModWizards.ts">');
$backupCTypeItems = $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'];
$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] = array(
    array(
        'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_tab_header',
        '--div--'
    ),
    array(
        'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world',
        'hello_world_ce',
        'i/tt_content_header.gif'
    )
);
foreach($backupCTypeItems as $key => $value){
    $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = $value;
}

这个问题经过编辑,但我认为有更好的方法来解决

只是为了弄清问题:

内容元素hello\u world\u ce未通过添加新内容元素添加到“类型”下拉列表中

问题中的提示是正确的,它没有为CType字段定义。 但您可以使用核心函数,而不是操纵数组:

 // Adds the content element to the "Type" dropdown
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
   array(
      'LLL:EXT:your_extension_key/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world',
      'hello_world_ce',
      'i/tt_content_header.gif'
   ),
   'CType',
   'your_extension_key'
);
下面是一个非常好的示例,说明如何在版本中添加您自己的内容元素


注:该功能在TYPO3 6.2中也可以访问

您可能还想查看此文档页面中流体样式的内容:(单击底部的“相关链接”选择TYPO3版本)