Core API

4.1.2. Extending the $TCA array

This is done by extensions and typically the information added to the table is stored in extension files named "ext_tables.php". Please see the Extension API description for details about this.

An example could look like this (from the extension "mininews", file "ext_tables.php"):

     1: // Defining a new column for the mininews extension (goes into the tt_content table)
     2: $tempColumns = Array (
     3:     "tx_mininews_frontpage_list" => Array (        
     4:         "exclude" => 1,        
     5:         "label" => "LLL:EXT:mininews/locallang_db.php:tt_content.tx_mininews_frontpage_list",
     6:         "config" => Array (
     7:             "type" => "select",
     8:             "items" => Array (
     9:                 Array("LLL:EXT:mininews/locallang_db.php:tt_content.tx_mininews_frontpage_list.I.0", "0"),
    10:                 Array("LLL:EXT:mininews/locallang_db.php:tt_content.tx_mininews_frontpage_list.I.1", "1"),
    11:             ),
    12:         )
    13:     ),
    14: );
    15: 
    16: // Make sure to load all of "tt_content":
    17: t3lib_div::loadTCA("tt_content");
    18: 
    19: // ... then add the column for mininews which was defined above:
    20: t3lib_extMgm::addTCAcolumns("tt_content",$tempColumns,1);
    21: 
    22: // ... and finally add the new column definition to the list of fields shown for the mininews plugin:
    23: // (This also removes the presence of the normally shown fields, "layout" and "select_key")
    24: $TCA["tt_content"]["types"]["list"]["subtypes_excludelist"][$_EXTKEY."_pi1"]="layout,select_key";
    25: $TCA["tt_content"]["types"]["list"]["subtypes_addlist"][$_EXTKEY."_pi1"]="tx_mininews_frontpage_list;;;;1-1-1";
    26: 
    27: // Now, define a new table for the extension. Name: "tx_mininews_news"
    28: // Only the "ctrl" section is defined since the rest of the config is in the "tca.php" file, loaded dynamically when needed.
    29: $TCA["tx_mininews_news"] = Array (
    30:     "ctrl" => Array (
    31:         "title" => "LLL:EXT:mininews/locallang_db.php:tx_mininews_news",
    32:         "label" => "title",    
    33:         "tstamp" => "tstamp",
    34:         "crdate" => "crdate",
    35:         "cruser_id" => "cruser_id",
    36:         "default_sortby" => "ORDER BY datetime DESC",    
    37:         "delete" => "deleted",    
    38:         "enablecolumns" => Array (        
    39:             "disabled" => "hidden",    
    40:             "starttime" => "starttime",    
    41:             "endtime" => "endtime",    
    42:             "fe_group" => "fe_group",
    43:         ),
    44:         "dynamicConfigFile" => t3lib_extMgm::extPath($_EXTKEY)."tca.php",
    45:         "iconfile" => t3lib_extMgm::extRelPath($_EXTKEY)."icon_tx_mininews_news.gif",
    46:     ),
    47:     "feInterface" => Array (
    48:         "fe_admin_fieldList" => "hidden, starttime, endtime, fe_group, datetime, title, teaser, full_text, front_page",
    49:     )
    50: );
    51: 
    52: // Then, make sure records from this table is allowed on regular pages:
    53: t3lib_extMgm::allowTableOnStandardPages("tx_mininews_news");
    54: // ... and allowed to be added in the "Insert Record" content element type:
    55: t3lib_extMgm::addToInsertRecords("tx_mininews_news");

Here line 1-25 is about adding a column to the table "tt_content" which was in fact added by the extension "cms"

Then line 27-55 shows how a totally new table is added for the extension "mininews".

To top


Valid XHTML 1.0!