1

I want to add some custom fields to the news records. But I want them to appear in the already existing "General" tab and not in a new tab "Extended" which is automatically created, when adding new fields.

I extend the news in the file <theme_extension>/Configuration/TCA/Overrides/tx_news_domain_model_news.php.

But I don't konw how to specify, where the fields appear.

Any help is appreciated, thanks in advance.

Philly

Albina
  • 1,901
  • 3
  • 7
  • 19
PHilgarth
  • 285
  • 1
  • 3
  • 19

2 Answers2

1

The best way is to use the ExtensionManagementUtility. To add a custom field in the general-tab i.e. after the title field, you could add this file in:

EXT:theme_extension/Configuration/TCA/overrides/tx_news_domain_model_news.php

<?php

defined('TYPO3') or die();

$fields = [
    'my_cool_custom_field' => [
        'label' => 'My cool custom field',
        'config' => [
            'type' => 'text',
            'cols' => 40,
            'rows' => 15,
            'eval' => 'trim',
        ]
    ],
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tx_news_domain_model_news', $fields);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'tx_news_domain_model_news',
    'my_cool_custom_field',
    '',
    'after:title'
);

You have some options to specify, where your field should appear. (before, after, after:palette:mypalette). Read the docs for more information:

https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/HowTo/ExtendingTca/Examples/Index.html

Mogens
  • 548
  • 1
  • 3
  • 10
-1

The position of your fields in the TCEform is done in the commaseparated list of $GLOBALS['tx_news_domain_model_news']['types'][<type>]['showitem'].

You have 2 options:

  1. Do a str_replace() to set your fields into the correct position.
  2. Use the package tcabuilder and the easy-to-handle configuration
Thomas Löffler
  • 5,922
  • 1
  • 14
  • 29