Login / Status
developer.Resource
Home . Documentation . Document Library . Core Documentation
Sponsors
hosted by punkt.deTYPO3 and Open Source MagazineAOE Media

4.3. Additional $TCA features

Special Configuration introduction

In relation to "types"-configuration it is possible to pass special parameters to a field only for certain type-configurations. For instance you can define that a text field should not wrap text lines when displayed by a certain types configuration:

'0' => Array('showitem' => 'hidden;;1, type, title, test_template, TEST01;;;nowrap'),

Notice the keyword "nowrap" in position 4 for the field "TEST01". TEST01 itself is defined like this in [columns]:

        'TEST01' => Array (

            'label' => 'TEST01: Text field',

            'config' => Array (

                'type' => 'text',

            )

        ),

The result becomes a small textarea field where lines are not broken automatically. This is very useful for entering codes:

The point of setting "nowrap" in the types configuration is that under other "types"-configurations the field will wrap lines. Likewise you can configure an RTE to appear for a field only if a certain type of the record is set and in other cases not.

Default Special Configuration (defaultExtras)

Since "types"-configuration does not apply for FlexForms and since a feature available as special configuration is sometimes needed regardless of type value you can also configure the default value of the special configuration. This is done with a key in the ['columns'][fieldname] array. Thus, the alternative configuration for the example above could be:

        'TEST01' => Array (

            'label' => 'TEST01: Text field',

            'config' => Array (

                'type' => 'text',

            ),

            'defaultExtras' => 'nowrap'

        ),

        ....

    ),

    'types' => Array (

        '0' => Array('showitem' => 'hidden;;1, type, title, test_template, TEST01'),

This works equally well.

Special Configuration options

Keywords

This table lists the options for keywords in special configuration. Each keyword is followed by a value wrapped in [] (square brackets).

Keyword

Description

Value syntax

Examples

nowrap

Disables line wrapping in "text" type fields.

[no options]

richtext

Enables the RTE for the field and allows you to set which toolbar buttons are shown.

* or

keywords separated by "|"

richtext[cut|copy|paste] = only cut, copy and paste options are shown.

richtext[*]= all RTE options

See RTE API definition later for more details.

rte_transform

Configuration of RTE transformations and other options.

See table below for a list of the key values possible.

key1=value2|key2=value2|key3=value3|...

rte_transform[key1=value1|key2=value2|key3=value3]

fixed-font

Use a monospace font in “textarea” type fields.

[no options]

enable-tab

Enable tabulator inside “textarea” type fields.

[no options]

rte_only

If set, the field can only be edited with a Rich Text Editor - otherwise it will not show up.

boolean (0/1)

static_write

This allows to configure a field value to be written to a file.

See table below for value of f1-f5

f1|f2|f3|f4|f5

wizards

Used to specifically enable wizards configured for a field. See option "enableByTypeConfig" in the wizard configuration.

wizard-key1|wizard-key2|...

wizards[table]

rte_transform[] key/value pairs

Keyword

Description

Value syntax

Examples

flag

This points to a field in the row which determines whether or not the RTE is disabled. If the value of the field is set, then the RTE is disabled.

Fieldname

rte_transform[flag=rte_disable]

mode

Configures which transformations the content will pass through between the database and the RTE application.

Transformation keywords separated by dashes ("-").

The order is calling order when direction is "db".

See RTE API section for list of transformations available.

rte_transform[mode=ts_css-images]

imgpath

This sets an alternative path for Rich Text Editor images. Default is configured by the value TYPO3_CONF_VARS["BE"]["RTE_imageStorageDir"] (default is “uploads/”)

path relative to PATH_site, eg. “uploads/rte_test/”

Example - Setting up Rich Text Editors

This sets up a Rich Text Editor with all possible tool bar buttons available, no transformations added or anything else:

        'TEST01' => Array (

            'label' => 'TEST01: Text field',

            'config' => Array (

                'type' => 'text',

            ),

            'defaultExtras' => 'richtext[*]'

        ),

This example is from the "mininews" extension which offers a RTE for editing the content of website news. This includes a limited list of toolbar buttons and a transformation of content ("ts_css") as well as a definition of an alternative storage path for uploaded images in the RTE ("uploads/tx_mininews/rte/")

richtext[cut|copy|paste|formatblock|textcolor|bold|italic|underline|left|center|right|orderedlist|unorderedlist|outdent|indent|link|table|image|line|chMode]:rte_transform[mode=ts_css|imgpath=uploads/tx_mininews/rte/]

The configuration for the RTE in the Content Elements is very similar regarding the enabled buttons. But the "rte_transform" values are slightly different. Here the field "rte_enabled" will disable the RTE if true (this field is a checkbox) and the transformation is "ts".

rte_transform[flag=rte_enabled|mode=ts]

static_write[] parameters

Keyword

Description

f1

The field name which contains the name of the file being edited. This filename should be relative to the path configured in $TYPO3_CONF_VARS[“BE”][“staticFileEditPath”] (which is "fileadmin/static/" by default).

f2

The field name which will also receive a copy of the content (in the database).

This should probably be the field name that carries this configuration.

f3

The field name containing the alternative subpart marker used to identify the editable section in the file.

The default marker is ###TYPO3_STATICFILE_EDIT### and may be encapsulated in HTML comments. There must be two markers, one to identify the beginning and one for the end of the editable section.

Optional.

f4

The field name of the record which - if true - indicates that the content should always be loaded into the form from the file and not from the duplicate field in the database.

f5

The field name which will receive a status message as a short text string.

Optional.

Example - Write to static file

This setup configures two fields in a record to point to a file and edit content in it between two markers:

        'TEST01' => Array (

            'label' => 'TEST01: Text field',

            'config' => Array (

                'type' => 'text',

            ),

            'defaultExtras' => 'static_write[TEST02|TEST01|||]'

        ),

The field "TEST02" must contain a filepath relative to "fileadmin/static/". In this case the filename is "static_write_file.txt".

The content of "fileadmin/static/static_write_file.txt" is like this:

outside
###TYPO3_STATICFILE_EDIT###
Hello World!
###TYPO3_STATICFILE_EDIT###

outside below

When the content of the "TEST01" field is edited the content between the markers "###TYPO3_STATICFILE_EDIT###" is updated as well.

You can study a fullblown configuration of these features in the extension called "static_file_edit".

Soft References

"Soft References" are references to database elements, files, email addresses, URls etc. which are found in-text in content. The <link [page_id]> tag from typical bodytext fields are an example of this.

The Soft Reference parsers are used by the system to find these references and process them accordingly in import/export actions and copy operations. Also, the soft references are utilized by integrity checking functions.

Default soft reference parsers

The class “t3lib_softrefproc” contains generic parsers for the most well-known types which are default for most TYPO3 installations. This is the list of the possible keys:

“softref” key:

Description:

substitute

A full field value targeted for manual substitution (for import /export features)

notify

Just report if a value is found, nothing more.

images

HTML <img> tags for RTE images / images from fileadmin/

typolink

References to page id or file, possibly with anchor/target, possibly comma separated list.

typolink_tag

As typolink, but searching for <link> tag to encapsulate it.

TSconfig

Processing (filerefs? Domains? what do we know...)

TStemplate

freetext references to "fileadmin/" files. HTML resource links like <a>, <img>, <form>

ext_fileref

Relative file reference, prefixed "EXT:[extkey]/" - for finding extension dependencies

email

Email highlight

url

URL highlights (with a scheme)

These are by default set up in the config_default.php file:

'SC_OPTIONS' => Array(
'GLOBAL' => array(
'softRefParser' => array(
'substitute' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'notify' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'images' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'typolink' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'typolink_tag' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'TSconfig' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'TStemplate' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'ext_fileref' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'email' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
'url' => 't3lib/class.t3lib_softrefproc.php:&t3lib_softrefproc',
)
)
),

User defined soft reference parsers

Soft References can also be user defined. It is easy to set them up by simply adding new keys in $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['softRefParser']. Use keynames based on the extension you put it in, eg. “tx_myextensionkey”.

The class containing the soft reference parser must have a function named “findRef”. Please refer to the class “t3lib_softrefproc” from t3lib/ for the API to use and return.

Wizards Configuration

Wizards are configurable for some field types, namely “input”, “text”, "select" and "group" types. They provide a way to insert helper-elements, links to wizard scripts etc.

A well known example of a wizard application is the form wizard:

The wizard is configured for the text area field and appears as an icon to the right. Clicking the icon will guide the user to a view where the "cryptic" form code is presented in a more user friendly interface:

Another example of wizards are the new / edit / list links which are available for "group" or "select" type fields:

Configuration of wizards

The value of the “wizards” key in the field config-array is an array. Each key is yet an array which configures the individual wizards for a field. The order of the keys determines the order the wizards are displayed. The key-values themselves play no important role (except from a few reserved words listetd in a table below).

The configuration for the new / edit / list links above looks like this:

   1: 'usergroup' => Array (

   2:     'label' => 'Group:',

   3:     'config' => Array (

   4:         'type' => 'select',

   5:         'foreign_table' => 'be_groups',

   6:         'foreign_table_where' => 'ORDER BY be_groups.title',

   7:         'size' => '5',

   8:         'maxitems' => '20',

   9:         'wizards' => Array(

  10:             '_PADDING' => 1,

  11:             '_VERTICAL' => 1,

  12:             'edit' => Array(

  13:                 'type' => 'popup',

  14:                 'title' => 'Edit usergroup',

  15:                 'script' => 'wizard_edit.php',

  16:                 'popup_onlyOpenIfSelected' => 1,

  17:                 'icon' => 'edit2.gif',

  18:                 'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',

  19:             ),

  20:             'add' => Array(

  21:                 'type' => 'script',

  22:                 'title' => 'Create new group',

  23:                 'icon' => 'add.gif',

  24:                 'params' => Array(

  25:                     'table'=>'be_groups',

  26:                     'pid' => '0',

  27:                     'setValue' => 'prepend'

  28:                 ),

  29:                 'script' => 'wizard_add.php',

  30:             ),

  31:             'list' => Array(

  32:                 'type' => 'script',

  33:                 'title' => 'List groups',

  34:                 'icon' => 'list.gif',

  35:                 'params' => Array(

  36:                     'table'=>'be_groups',

  37:                     'pid' => '0',

  38:                 ),

  39:                 'script' => 'wizard_list.php',

  40:             )

  41:         )

  42:     )

  43: ),

The wizard configuration takes place in line 9 and throughout. Two reserved keywords are used in line 10 and 11 to set arrangement settings for the display of icons.

Then a new wizard is configured in lines 12 (edit), 20 (add) and 31 (list).

Reserved keys

Each wizard is identified by a key string. However some strings are reserved for general configuration. These are listed in this table and as a rule of thumb they are prefixed with an underscore ("_"):

Key

Type

Description

_POSITION

string

Determines the position of the wizard-icons/titles.

Default is “right”.

Possible values are “left”, “top”, “bottom”.

_ VERTICAL

boolean

If set, the wizard icons (if more than one) will be positioned in a column (vertically) and not a row (horizontally, which is default)

_ DISTANCE

int+

The distance in pixels between wizard icons (if more than one).

_PADDING

int+

The cellpadding of the table which keeps the wizard icons together.

_VALIGN

string

valign attribute in the table holding things together.

_HIDDENFIELD

boolean

If set, the field itself will be a hidden field (and so not visible...)

[any other key]

PHP-Array

Configuration of the wizard types, see below.

General configuration options

This table lists the general configuration options for (almost) all wizard types. In particular the value of the "type" key is important because it denotes what additional options are available.

Key

Type

Description

type

string

Defines the type of wizard. The options are listed as headlines in the table below.

This setting is required!

title

string (LS)

This is the title of the wizard. For those wizards which require a physical representation - eg a link - this will be the link if no icon is presented.

icon

fileref

This is the icon representing the wizard.

If the first 3 chars are NOT “../” then the file is expected to be in “t3lib/gfx/”. So to insert custom images, put them in “../typo3conf/” or so. You can also prefix icons from extensions with "EXT:ext/[extension key]/directory.../". Generally, the format is the same as for referring to icons for selector box options.

If the icon is not set, the title will be used for the link.

enableByTypeConfig

boolean

If set, then the wizard is enabled only the in Special Configuration in the types are set to “wizards[list of wizard-keys]”. See wizard section.

RTEonly

boolean

If set, then this wizard will appear only if the wizard is presented for a RTE field.

hideParent

array

If set, then the real field will not be shown (but rendered as a hidden field). In “hideParent” you can configure the non-editable display of the content as if it was a field of the “none” type. The options are the same as for the “config” key for “none” types.

Specific wizard configuration options based on type

Key

Type

Description

Type: script

Creates a link to an external script which can do "context sensitive" processing of the field. This is how the Form and Table wizards are used.

  

notNewRecords

boolean

If set, the link will appear only if the record is not new (that is, it has a proper UID)

script

PHP-script filename

If the first 3 chars are NOT “../” then the file is expected to be in “typo3/”. So to link to custom script, put it in “../typo3conf/”. File reference can be prefixed "EXT:[extension key]/" to point to a file inside an extension.

A lot of parameters are passed to the script as GET-vars in an array, P.

params

array

Here you can put values which are passed to your script in the P array.

popup_onlyOpenIfSelected

boolean

If set, then an element (one or more) from the list must be selected. Otherwise the popup will not appear and you will get a message alert instead. This is supposed to be used with the wizard_edit.php script for editing records in "group" type fields.

Type: popup (+colorbox)

Creates a link to an external script opened in a pop-up window.

  

notNewRecords

boolean

See above, type “script”

script

PHP-script filename

See above, type “script”

params

See above, type “script”

JSopenParams

string

Parameters to open JS window:

Example:

"JSopenParams" => "height=300,width=250,status=0,menubar=0,scrollbars=1",

Type: userFunc

Calls a user function/method to produce the wizard or whatever they are up to.

  

notNewRecords

boolean

See above, type “script”

userFunc

string

Calls a function or a method in a class.

Methods: [classname]->[methodname]

Functions: [functionname]

The function/class must be included on beforehand. This is adviced to be done within the localconf.php file.

Two parameters are passed to the function/method: 1) An array with parameters, much like the ones passed to scripts. One key is special though: the “item” key, which is passed by reference. So if you alter that value it is reflected back! 2) $this (reference to the TCEform-object).

The content returned from the function call is inserted at the position where the the icon/title would normally go.

Type: colorbox

Renders a square box (table) with the background color set to the value of the field. The id-attribute is set to a md5-hash so you might change the color dynamically from pop-up- wizard.

The icon is not used, but the title is given as alt-text inside the color-square.

  

dim

W x H, pixels

Determines the dimensions of the box. Default is 20 pixels.

"dim" => "50x20",

tableStyle

style-attribute content in table-tag

Sets the border style of the table, eg:

"tableStyle" => "border:solid 1px black;"

exampleImg

string

Reference to a sample (relative to PATH_typo3 directory).

You can prefix with "EXT:" to get image from extension.

An image width of 350 is optimal for display.

Example:

'exampleImg' => 'gfx/wizard_colorpickerex.jpg'

Type: select

This renders a selector box. When a value is selected in the box, the value is transferred to the field and the field (default) element is thereafter selected (this is a blank value and the label is the wizard title).

“select” wizards make no use of the icon.

The “select” wizard's select-properties can be manipulated with the same number of TSconfig options which are available for “real” select-types in TCEFORM.[table].[field]. The position of these properties is “TCEFORM.[table].[field].wizards.[wizard-key]”.

  

mode

append, prepend, [blank]

Defines how the value is processed: Either added to the front or back or (default) substitutes the existing.

items,

foreign_table_

etc...

Options related to the selection of elements known from “select” form-element type in $TCA.

Example:

"items" => Array(

Array("8 px","8"),

Array("10 px","10"),

Array("11 px","11"),

Array("12 px","12"),

Array("14 px","14"),

Array("16 px","16"),

Array("18 px","18"),

Array("20 px","20")

)

In the next section all the default core wizard scripts are demonstrated with examples. Before that, here is a few examples of wizards that does not require an external script.

Example - Selector box of preset values

You can add a selector box containing preset values next to a field:

When an option from the selector box is selected it will be transferred to the input field of the element. The mode of transfer can be either substitution (default) or prepending or appending the value to the existing value.

The example above is achieved by this configuration:

   1: 'TEST01' => Array (

   2:     'label' => 'TEST01: Preset values',

   3:     'config' => Array (

   4:         'type' => 'input',

   5:         'size' => '10',

   6:         'wizards' => array(

   7:             'select' => array(

   8:                 'type' => 'select',

   9:                 'mode' => '',

  10:                 'items' => array(

  11:                     array('Label 1', 'Value 1'),

  12:                     array('Label 2', 'Value 2'),

  13:                     array('Label 3', 'Value 3'),

  14:                 )

  15:             ),

Example - User defined wizard (processing with PHP function)

The "userFunc" type of wizard allows you to render all the wizard code yourself. Theoretically, you could produce all of the other wizard kinds ("script", "popup", "colorbox" etc) with your own user function rendering the similar HTML.

In this example I will do two things with the wizard:

  1. show how you can manipulate the HTML code of the form field the wizard is attached to

  2. Add two links which access the content of the form field.

The result looks like this:

The configuration needed is this:

   1: 'wizards' => array(

   2:     'uproc' => array(

   3:         'type' => 'userFunc',

   4:         'userFunc' => 'user_class->user_TCAform_procWizard',

   5:         'params' => array(

   6:             'wrapTag' => 'u'

   7:         )

   8:     ),

And obviously, you need the code listing of the class, "user_class", as well:

   1: class user_class {

   2:     function user_TCAform_procWizard($PA, $fobj)    {

   3:             // Wrapping the field item in a <div> with border.

   4:             // Notice that $PA['item'] is passed by reference, so any manipulation

   5:             // is automatically affecting the field without explicitly returning a value!

   6:         $PA['item'] = '<div style="border: maroon 4px dashed;">'.$PA['item'].'</div>';

   7:

   8:             // Adding wizard HTML code: Showing value in JavaScript ALERT box:

   9:         $onclick = "alert('This is the field value: ' + ".

  10:                     "document.".$PA['formName']."['".$PA['itemName']."'].value);".

  11:                     "return false;";

  12:         $output = '<a href="#" onclick="'.htmlspecialchars($onclick).'">[Show field value]</a><br/>';

  13:

  14:             // Adding wizard HTML code: Showing value in JavaScript ALERT box:

  15:         $wTagBegin = '<'.$PA['params']['wrapTag'].'>';

  16:         $wTagEnd = '</'.$PA['params']['wrapTag'].'>';

  17:         $onclick = "document.".$PA['formName']."['".$PA['itemName']."'].value=".

  18:                     "'".$wTagBegin."' + document.".$PA['formName']."['".$PA['itemName']."'].value + '".$wTagEnd."';".

  19:                     implode('',$PA['fieldChangeFunc']).    // Necessary to tell TCEforms that the value is updated.

  20:                     "return false;";

  21:         $output.= '<a href="#" onclick="'.htmlspecialchars($onclick).'">'.

  22:                     htmlspecialchars('[Wrap in '.$wTagBegin.'...'.$wTagEnd.']').

  23:                     '</a>';

  24:

  25:             // Return Wizard HTML:

  26:         return $output;

  27:     }

  28: }

In line 6 you see how the form field is wrapped in a <div> tag. Notice how all you need to do is to change the value of $PA['item'] since that value is passed by reference to the function and therefore doesn't need a return value - only to be changed.

In line 9-12 you see the first link created. It just reads the current value of the <input> field and shows in an alert box.

In line 15-23 you see how the value of the key "wrapTag" from the "params" array (reserved space for user defined parameters) is used to create a link which will wrap whatever content of the input field in an HTML tag, in this case a <u> tag.

Finally the wizard HTML created is returned.

Obviously you will have to find out what kind of information is hidden in the $PA variable. A TYPO3 specific way of doing this is to use "debug($PA);" which will output the content of the array in a nicely formatted table. In PHP there are native functions like "print_r" or "vardump".

Wizard scripts in the core

The wizard interface allows you to use any PHP-script for your wizards but there is a useful set of default wizard scripts available in the core of TYPO3. These are found in PATH_typo3 and are all prefixed "wizard_" (except "browse_links.php").

Below is a description of each of them including a description of their special parameters and an example of usage.

wizard_add.php

This script links to a form which allows you to create a new record in a given table which may optionally be set as the value on return to the real form.

Key

Type

Description

table

string

Table to add record in.

pid

int

pid of the new record.

You can use the “markers” (constants) as values instead if you wish:

###CURRENT_PID######THIS_UID######STORAGE_PID######SITEROOT###

(see TCA/select for description)

setValue

“prepend”, “set”, “append”

“set” = the field will be force to have the new value on return

“append”/“prepend” = the field will have the value appended/prepended.

You must set one of these values.

In this example I have added the wizard script "wizard_add.php" to the well known Frontend User Group selector:

When the wizard icon is clicked the user is directed to a form where a new frontend user group can be created:

When the new group is saved and the user clicks the close button of the form the new group is automatically inserted as the current value.

The configuration looks like this:

   1: 'fe_group' => Array (
   2:     'exclude' => 1,
   3:     'label' => 'LLL:EXT:lang/locallang_general.php:LGL.fe_group',
   4:     'config' => Array (
   5:         'type' => 'select',
   6:         'items' => Array (
   7:             Array('', 0),
   8:             Array('LLL:EXT:lang/locallang_general.php:LGL.hide_at_login', -1),
   9:             Array('LLL:EXT:lang/locallang_general.php:LGL.any_login', -2),
  10:             Array('LLL:EXT:lang/locallang_general.php:LGL.usergroups', '--div--')
  11:         ),
  12:         'foreign_table' => 'fe_groups',

  13:         'wizards' => array(

  14:             'add' => Array(

  15:                 'type' => 'script',

  16:                 'title' => 'Add Frontend Group',

  17:                 'icon' => 'add.gif',

  18:                 'params' => Array(

  19:                     'table' => 'fe_groups',

  20:                     'pid' => '###STORAGE_PID###',

  21:                     'setValue' => 'set'

  22:                 ),

  23:                 'script' => 'wizard_add.php'

  24:             ),

  25:         )

  26:     )

  27: ),

Line 15 defines the type to be "script" which is set to "wizard_add.php" in line 23. The parameters that instructs the Add-wizard how to handle the creation is done in line 19-21; The table is of course fe_groups and the pid where the user is created is the Storage Folder set for the website. Of course this requires a storage folder to exist. Finally, "setValue" tells the wizard script that the uid of the new record should substitute any current value.

wizard_edit.php

The Edit wizard gives you a shortcut to edit references in "select" or "group" type form elements.

The configuration below is what sets up this wizard.

   1: 'wizards' => array(

   2:     'edit' => Array(

   3:         'type' => 'popup',

   4:         'title' => 'Edit usergroup',

   5:         'script' => 'wizard_edit.php',

   6:         'icon' => 'edit2.gif',

   7:         'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',

   8:     ),

This time the type fitting the wizard script best is the "popup" type. It could have been the "script" type as well, but it just works slightly better in this case if it is a pop-up so we don't leave the original form.

There are no parameters to pass along like there were for the Add wizard.

wizard_list.php

This links to the Web>List module for only one table and allows the user to manipulate stuff there.

By clicking the icon you will get to the Web>List module. Notice how the "Back" link is found in the upper right corner, taking you back to the edit form.

This wizard has a few parameters to configuration in the "params" array:

Key

Type

Description

table

string

Table to manage records for

pid

int

id of the records you wish to list.

You can use the “markers” (constants) as values instead if you wish:

###CURRENT_PID######THIS_UID######STORAGE_PID######SITEROOT###

(see TCA/select for description)

The configuration look like this:

   1: 'wizards' => array(

   2:     'list' => Array(

   3:         'type' => 'script',

   4:         'title' => 'List groups',

   5:         'icon' => 'list.gif',

   6:         'params' => Array(

   7:             'table'=>'fe_groups',

   8:             'pid' => '###STORAGE_PID###',

   9:         ),

  10:         'script' => 'wizard_list.php',

  11:     ),

The type is also the "script" type. In the "params" array the table and pid passed to the script is set.

wizard_colorpicker.php

The colorpicker wizard allows you to select a HTML color value from a user friendly pop-up box. The wizard type is "colorbox" which will first of all add a colored box next to an input field:

The color of the box is set to the value of the text field. Clicking the box will open a popup window with the color picker wizard script showing itself:

Here you can select from the web-color matrix, pick a color from the sample image or select a HTML-color name from a selector box.

The configuration needed looks like this:

   1: 'TEST01' => Array (

   2:     'label' => 'TEST01: Color picker wizard',

   3:     'config' => Array (

   4:         'type' => 'input',

   5:         'size' => '30',

   6:         'wizards' => array(

   7:             'colorpick' => array(

   8:                 'type' => 'colorbox',

   9:                 'title' => 'Color picker',

  10:                 'script' => 'wizard_colorpicker.php',

  11:                 'dim' => '20x20',

  12:                 'tableStyle' => 'border: solid 1px black; margin-left: 20px;',

  13:                 'JSopenParams' => 'height=550,width=365,status=0,menubar=0,scrollbars=1',

  14:                 'exampleImg' => 'gfx/wizard_colorpickerex.jpg',

  15:             )

  16:         )

  17:     )

  18: ),

Notice the wizard type is "colorbox".

wizard_forms.php

The forms wizard is used typically with the Content Elements, type "Mailform". It allows to edit the code-like configuration of the mail form with a nice editor. This is shown in the introduction to Wizards above.

This is the available parameters:

Key

Type

Description

xmlOutput

boolean

If set, the output from the wizard is XML instead of the strangely formatted TypoScript form-configuration code.

The configuration used for the editor in Content Elements looks like this:

'forms' => Array(

    'notNewRecords' => 1,

    'enableByTypeConfig' => 1,

    'type' => 'script',

    'title' => 'Forms wizard',

    'icon' => 'wizard_forms.gif',

    'script' => 'wizard_forms.php?special=formtype_mail',

    'params' => array('xmlOutput' => 0)

)

wizard_table.php

The tables wizard is used typically with the Content Elements, type "Table". It allows to edit the code-like configuration of the tables with a nice editor.

This is the available parameters:

Key

Type

Description

xmlOutput

boolean

If set, the output from the wizard is XML instead of the TypoScript form-configuration code.

numNewRows

integer

Setting the number of blank rows that will be added in the bottom of the table when the plus-icon is pressed. The default is 5, the range is 1-50.

This is the configuration code used for the table wizard in the Content Elements:

'table' => Array(

    'notNewRecords' => 1,

    'enableByTypeConfig' => 1,

    'type' => 'script',

    'title' => 'Table wizard',

    'icon' => 'wizard_table.gif',

    'script' => 'wizard_table.php',

    'params' => array('xmlOutput' => 0)

),

wizard_rte.php

This wizard is used to show a "full-screen" Rich Text Editor field. The configuration below shows an example taken from the Text field in  Content Elements:

'RTE' => Array(

    'notNewRecords' => 1,

    'RTEonly' => 1,

    'type' => 'script',

    'title' => 'LLL:EXT:cms/locallang_ttc.php:bodytext.W.RTE',

    'icon' => 'wizard_rte2.gif',

    'script' => 'wizard_rte.php',

),

wizard_tsconfig.php

This wizard is used for the TSconfig fields and TypoScript Template "Setup" fields. It is specialized for that particular situations and it is not likely you will need it for anything on your own.

browse_links.php

The "Links" wizard is used many places where you want to insert link references. Not only in the Rich Text Editor but also in "typolink" fields:

Clicking the wizard icons opens the Element Browser window:

Such a wizard can be configured like this:

'link' => Array(

    'type' => 'popup',

    'title' => 'Link',

    'icon' => 'link_popup.gif',

    'script' => 'browse_links.php?mode=wizard',

    'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'

)

Notice how the "browse_links.php" script requires an extra parameter since it has to return content back to the input field (and not the RTE for instance which it also supports).

$PAGES_TYPES

$PAGES_TYPES defines the various types of pages (field: doktype) the system can handle and what restrictions may apply to them. Here you can set the icon and especially you can define which tables are allowed on a certain pagetype (doktype).

NOTE: The "default" entry in the $PAGES_TYPES-array is the "base" for all types, and for every type the entries simply overrides the entries in the "default" type!!

This is the default array as set in t3lib/stddb/tables.php:

$PAGES_TYPES = Array(

    '254' => Array(        //  Doktype 254 is a 'sysFolder' - a general purpose storage

        'type' => 'sys',

        'icon' => 'sysf.gif',

        'allowedTables' => '*'

    ),

    '255' => Array(        // Doktype 255 is a recycle-bin.

        'type' => 'sys',

        'icon' => 'recycler.gif',

        'allowedTables' => '*'

    ),

    'default' => Array(

        'type' => 'web',

        'icon' => 'pages.gif',

        'allowedTables' => 'pages',

        'onlyAllowedTables' => '0'

    )

);

Each array has the following options available:

Key

Description

type

Can be "sys" or "web"

icon

Alternative icon.

The file reference is on the same format "iconfile" in [ctrl] section of TCA

allowedTables

The tables that may reside on pages with that "doktype".  

Commalist with tables allowed on this page doktype. "*" = all

onlyAllowedTables

Boolean. If set, the tce_main class will not allow a shift of doktype if unallowed records are on the page.

Notice: All four options must be set for the default type while the rest can choose as they like.

White $PAGES_TYPES is most significant, there are a few other global variables which deserves a mention in relation to $TCA:

$ICON_TYPES

With $ICON_TYPES you can assign alternative icons to pages records based on the field 'module' in pages table. Each key is a value from the "module" field of page records and the value is an array with a key/value pair, eg. "icon" => "modules_shop.gif". The file reference is on the same format "iconfile" in [ctrl] section of TCA

This is the configuration found in "cms" extension and setting icons for some legacy extensions:

    // Setting ICON_TYPES

    $ICON_TYPES = Array(

        'shop' => Array('icon' => 'modules_shop.gif'),

        'board' => Array('icon' => 'modules_board.gif'),

        'news' => Array('icon' => 'modules_news.gif'),

        'dmail' => Array('icon' => 'modules_dmail.gif'),

        'fe_users' => Array('icon' => 'modules_fe_users.gif'),

        'approve' => Array('icon' => 'modules_approvals.gif')

    );

Usage of $ICON_TYPES is deprecated.

$LANG_GENERAL_LABELS

Commonly used language labels which can be used in the $TCA array and elsewhere. Has become obsolete - just use the values of each entry directly.

For backwards compatibility $LANG_GENERAL_LABELS are still available but deprecated. This is the default values:

$LANG_GENERAL_LABELS = array(

    'endtime' => 'LLL:EXT:lang/locallang_general.php:LGL.endtime',

    'hidden' => 'LLL:EXT:lang/locallang_general.php:LGL.hidden',

    'starttime' => 'LLL:EXT:lang/locallang_general.php:LGL.starttime',

    'fe_group' => 'LLL:EXT:lang/locallang_general.php:LGL.fe_group',

    'hide_at_login' => 'LLL:EXT:lang/locallang_general.php:LGL.hide_at_login',

    'any_login' => 'LLL:EXT:lang/locallang_general.php:LGL.any_login',

    'usergroups' => 'LLL:EXT:lang/locallang_general.php:LGL.usergroups',

);

Loading the full $TCA dynamically

You may load table descriptions dynamically (as needed) from separate files using the function t3lib_div::loadTCA($tablename) where $tablename is the name of the table you wish to load a complete description of.

Dynamic tables must always be configured with a full [ctrl]-section (and [feInterface] section if needed). That is, it must be represented by $TCA[$table]['ctrl']. If the table is dynamic, the value of [ctrl][dynamicConfigFile] points to an includefile with the full array in.

The loadTCA-function determines whether a table is fully loaded based on whether $TCA[$table][columns] is an array. If it is found to be an array the function just returns - else it loads the table if there is a value for “dynamicConfigFile”

The table “pages” must not be dynamic. All others can be in principle. You can also define more than one table in a dynamicConfigFile - as long as the $TCA array is correctly updated with table information it doesn't matter if a file contains configuration for more than the requested table - although the requested table should of cause always be configured, because it's expected to be. In fact there is not much error checking; The function loadTCA simply includes the file in blind faith that this action will fully configure the table in question.

Locating places where t3lib_div::loadTCA call is needed

To find places in your backend code where this should probably be implemented search for:

"each($TCA)" - This is potentially dangerous in a construction like this:

while(list($table,$config)=each($TCA))

where $config would obtain non-complete content. Instead it should look like:

while(list($table)=each($TCA)){
t3lib_div::loadTCA($table);
$config=$TCA[$table]
...
}

\[“?(palettes|types|columns|interface)”?\] (regex) - to find places where the palettes, types, columns and interfaces keys are used - which would require the whole array to be loaded!

It's recommended to always call the function t3lib_div::loadTCA() before using the non-[ctrl] sections of the $TCA array. The function returns immediately if the table is already loaded, so the overhead should be small and the importance is great.

Benchmarks on dynamic tables:

Module

tables.php with all configuration

Dynamic loading

   

Cache

No cache

Cache

No cache

 

Web>List (loads all)

173 ms

322 ms

177 ms

328 ms

 

Web>Info (loads none)

72 ms

174 ms

66 ms

136 ms

 

Benchmarks on a PIII/500 MHz Linux PHP4.1.2/Apache, 256 MB RAM. PHP-Cache is PHP-accelerator. All figures are parsetimes in milliseconds.

Analysis:

Analysis:

What we see is, when showing a page in Web>List where all tables are loaded, the dynamic loading of tables includes a little overhead (177-173=4 ms) regardless of script-caching. This seems fair, probably due to file operations. It's also evident that the script-caching boosts the parsing considerably in both cases, saving approximately 150 ms in parsetime!

The Web>Info module does not load any tables (at least not in the mode, this was tested). This is the whole point of all this - that the full table definitions are loaded only if needed (as they were by the Web>List module). Again the point of caching is clear. But the main thing to look at is, that the Web>Info module is loaded in 66/136 seconds (cache/non-cache) with dynamic loading (was later tested to 60/118 ms when tt_content was not loaded by default) which is LOWER than if the whole tables.php was included (72/174 ms).

At this point the performance gain is not significant but welcomed. However the mechanism of dynamic loading of tables provides the basis for much greater number of tables in TYPO3. Testing 31 duplicates of the tt_content table added to the default number of configured tables (total of 62 tables configured) gave this benchmark:

Module

Dynamic loading

 

Cache

No cache

Web>List (loads all)

580 ms

1090 ms

Web>Info (loads none)

67 ms

139 ms

This shows once again the work of the caching (1090-580 ms gained by PHPA) but clearly demonstrates the main objective of dynamic loading; The Web>Info module is not at all affected by the fact that 31 big tables has been added.

The serialized size of the $TCA in this case was measured to approx 2MB. The total number of KB in table-definition PHP-files was approx. 1.7 MB.

Extreme tests of this configuration has also been done.

A duplicate of tt_content was added x number of times and yielded these results:

Number of tt_content dupl.

Serialized size of $TCA

Max size of httpd proces (from “top”)

Parsetime of the included documents

100

5,9 MB

23 MB

380 ms

250

14,5 MB

52 MB

12000 ms

500

28,8 MB

100 MB

x

The configuration of tt_content is approx. 52 kb PHP code. The testing was done just loading the content into $TCA - no further processing. However serializing the $TCA array (when that was tested) gave a double up on the amount of memory the httpd process allocated. This was to expect of course.

From this table we learn, that PHP does not crash testing this. However it makes not much sense to use 500 tables of this size. 250 tables might be alright and 100 tables is a more realistic roof over the number of tables in TYPO3 of the size of tt_content!

Conducting the same experiment with a table configuration of only 8 kb with 9 fields configured (a reduced configuration for the tt_content duplicate - which represents a more typical table) yielded these results:

Number of tables

Serialized size of $TCA

Max size of httpd process (from “top”)

Parsetime of the included documents

Web>List listing

1

240 kB

12 MB

0 ms

174 ms (12 MB)

100

1,0 MB

12 MB

77 ms

550 ms (12 MB)

250

2,4 MB

12 MB

200 ms

1050 ms (12 MB)

500

4,7 MB

22 MB

450 ms

1900 ms (20 MB)

1000

9,3 MB

33 MB

900 ms

5000 ms (34 MB)

2000

18,6 MB

51 MB

2000 ms

18000 ms (60 MB)



TYPO3 Core API

TSRef

TYPO3 Coding Guidelines