I'm new to Typo3. I want to add a custom content element with a specifc select field within this content element. For the custom content element, I modified the pageTSConfig with
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig and added my element. This is working. In order to store my content value, I added the "ext_tables.sql" file with
#
# Table structure for table 'tt_content'
#
CREATE TABLE tt_content (
tx_spk_shopware_category varchar(20) NULL
);
and finally I override the TCA configuration for tt_content and this is not working. I see the new content element with my custom type with my items within the config, but I cannot modify / add any items in the class referenced in itemsProcFunc.
tt_content.php:
<?php declare(strict_types=1);
defined('TYPO3_MODE') || die();
// static TypoScript
(static function () {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:spk_shopware/Resources/Private/Language/Tca.xlf:spk_shopware_category.wizard.title',
'spk_shopware_category',
'EXT:spk_shopware/Resources/Public/Icons/ContentElements/spk_shopware_category.gif'
),
'CType',
'spk_shopware'
);
$temporaryColumn = array(
'tx_spk_shopware_category' => array (
'exclude' => 1,
'label' => 'LLL:EXT:spk_shopware/Resources/Private/Language/Tca.xlf:spk_shopware_category.title',
'config' => array (
'type' => 'select',
'itemsProcFunc' => SPK\Shopware\Hook\ShopwareCategorySelect::class . '->listAvailableShopwareCategories',
'items' => array(
array('test 1', '8'),
array('test 2', '10'),
),
'maxitems' => 1,
'minitems' => 1,
'required' => true,
)
)
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$temporaryColumn
);
})();
// Configure the default backend fields for the content element
$GLOBALS['TCA']['tt_content']['types']['spk_shopware_category'] = array(
'showitem' => '
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xml:palette.general;general,
tx_spk_shopware_category
');
CategorySelect.php
<?php
namespace SPK\Shopware\Hook;
class ShopwareCategorySelect
{
public function listAvailableShopwareCategories(&$config)
{
$config['items'][] = ["Tim", 0];
$config['items'][] = ["Tom", 1];
$config['items'][] = ["Jerry", 2];
array_push($config['items'], ["as", 1]);
return $config;
}
}
I see the custom element and new select field, but only with the test elements in the config. I don't know what I'm missing.