NOTE: This post is intended to add a new field to an existing TYPO3 table at any desired position.
Kickstarter is initially used to add the new field, then we will use fthe following trick to add our new field to a desired location.
GOAL: Add new field called company name, after the subheader field for tt_news of type “External URLS”
STEP 1: Look into the ext_tables.php containing the following method of adding new field to TCA Array.
t3lib_div::loadTCA(‘tt_news’);
t3lib_extMgm::addTCAcolumns(‘tt_news’,$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes(‘tt_news’,’tx_ttnews_fieldcompany;;;;1-1-1′);
STEP 2: Replace the above 3 lines as follows:
t3lib_div::loadTCA(‘tt_news’);
t3lib_extMgm::addTCAcolumns(‘tt_news’,$tempColumns,1);
$TCA[‘tt_news’][‘types’][‘2’][‘showitem’] = str_replace(‘short,’, ‘short, tx_ttnews_fieldcompany,’, $TCA[‘tt_news’][‘types’][‘2’][‘showitem’]);
STEP 2: Alternate, using TYPO3 API (Thanks to Oliver for the code):
t3lib_div::loadTCA(‘tt_news’);
t3lib_extMgm::addTCAcolumns(‘tt_news’,$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes(“tt_news”,”tx_ttnews_fieldcompany;;;;1-1-1″, “”, “after:short”);
STEP 3 Clear cahce and check the news record.
That’s it, now clear your TYPO3 config cache, and check the record, the new field is now just after the sub header field in tt_news record of type External URL.