How to use tt_content fields in custom plugin of TYPO3.


 
How to add new field in custom plugin option

Its very important and useful for add tt_content field in custom plugin option or in normal content element area.

If you want to set second title field in your tt_content record then you have to set following script in your ext_table.php

$tempColumns = array(
    'subtitle' => array(
        'exclude' => 0,
        'label' => 'title2',
        'config' => array(
            'type' => 'input'
        )
    )
);

Then you have to load tt_content TCA file

This is for EXTBASE Extension
\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_content');

OR

This is for PI Base Extension
t3lib_div::loadTCA("tx_dam_cat");

If you want to display this field in ALL CONTENT ELEMENT then use following script.

This is for EXTBASE Extension
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $tempColumns);

OR

This is for PI Base Extension
t3lib_extMgm::addTCAcolumns("tx_dam_cat",$tempColumns,1);

Third parameter is deprecated in latest version of TYPO3 6.X.X

If you want to display this field in PARTICULAR EXTENSION then use following script.

This is for EXTBASE Extension
$TCA["tt_content"]["types"]["list"]["subtypes_excludelist"]["abc_xyz"]="layout,select_key,pages";
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"]["abc_xyz"]="subtitle;;;;1-1-1";

OR

This is for PI Base Extension
$TCA["tt_content"]["types"]["list"]["subtypes_excludelist"][$_EXTKEY."_pi1"]="layout,select_key,pages";
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"][$_EXTKEY."_pi1"]="subtitle;;;;1-1-1";

Note :
If your extension key is “Abc” and your plugin key is “Xyz”, then the index is “abc_xyz”, all in small.

I hope it will work for you and make your day 😉

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements