How to enable the subheader, but only for the custom extension in typo3 6.x backend?

1k Views Asked by At

I want the subheader to show up in my extension's content manager (Typo3 6.2.11 CMS backend). I therefore added the following line in ext_tables.php of my custom extension:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('tt_content','header','--linebreak--,subheader;LLL:EXT:cms/locallang_ttc.xlf:subheader_formlabel','after:header');

This helped me show subheader in my extension, but it is now also showing in the default content types which is undesired. How can I make it show up only inside my extension without affecting the other settings of default content types? Besides, I still need to rename subheading to something else. Any help would be appreciated.

2

There are 2 best solutions below

3
On

You may override the TCA of tt_content with your own extension, by placing tt_content.php in your_ext/Configuration/TCA/Overrides folder with following content:

$GLOBALS['TCA']['tt_content']['columns']['subheader']['displayCond'] = [
  'AND' => [
    'FIELD:CType:=:list',
    'FIELD:list_type:=:your_ext_signature',
]

Just exchange your_ext_signature with real signature, which you can find in DB for your plugin content element.

Read more about displayCond

0
On

With those instruction from @Viktor and some of my hit-and-trials, I arrived at the following solution that worked for me:

In my_ext/Configuration/TCA/Overrides/tt_content.php, I now have:

$GLOBALS['TCA']['tt_content']['columns']['subheader']['displayCond'] = [
    'AND' => [
        'FIELD:CType:=:my_ext_signature',
]];

I found my my_ext_signature inside the corresponding CType field of the table tt_content; so I used that for the above displayCond (my list_type however was empty so I did not make use of that).

Besides, I was able to rename subheading in the backend by adding the following in Resources property of Page: (Page > Right click globe icon > Edit from the menu > Resources):

TCEFORM.tt_content {
    subheader.label = My custom title that shows in backend form
}

I had to re-install the extension and clear my cache to see the final results.