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

1.8. Adding context sensitive help to custom table fields

All the default tables in Typo3 has context sensitive help for their fields. This is done through the centrally distributed tables sys_tabledescr*. However modifying these tables are not clever for custom purposes because the tables are meant to be updated by new Typo3 releases. Therefore a file-based concept has been introduced in parallel to the sys_tabledescr concept.

This is also demonstrated by the user_photomarathon example. All you have to do is to place a file named 'extTables_descr.php' in the typo3conf/ folder of your Typo3 site. The content of this file should be modelled after this principle:

<?php$TCA_DESCR["user_photomarathon"] = Array (    "columns" => Array (            "title" => Array(            "description"=> "Enter the title of the image.",            "details" => "This is displayed in the headers on the webpages.",            "image" => "../typo3conf/web/uPhotomarathon/someImage.gif",            "image_descr" => "Here you see the title",            "seeAlso" =>"user_photomarathon:description,user_photomarathon:images"        ),        "description" => Array(            "description"=>"Users may enter a description. This is shown with the image."        ),        "images" => Array(            "description"=>"The image. Users may upload up to 2 images."        ),        "photodate" => Array(            "description"=>"The date of the photo"        ),        "fe_cruser_id" => Array(            "description"=>"                This field contains a reference to the fe_user (website user) who owns it.                 You should not change this.                 If you remove the user, the image will no longer belong to him and he cannot ...                In addition if you simply insert another user, the image will belong to this ...            "        )    ));?>

Provided that the user has enabled field help texts (see below) this will look like this in the backend forms:

... and clicking the icon will bring up this pop-up window:

Changing the display type, the field help may also appear like this:

Adding a translation to the custom table descriptions

That's very easy. You just need to know the available language keys (must be one of them). Those are found in the t3lib/config_default.php script. In this case we select danish (which is “dk”). You simply make a copy of the 'extTables_descr.php' file and rename it 'extTables_descr_dk.php':

<?php$TCA_DESCR_DK["user_photomarathon"] = Array (    "columns" => Array (            "description" => Array(            "description"=>"Beskrivelse af billedet"        ),        "images" => Array(            "description"=>"Brugerne kan uploade op til 2 billeder."        ),        "photodate" => Array(            "description"=>"Datoen for fotografiet."        ),        "fe_cruser_id" => Array(            "description"=>"Reference til brugeren, som ejer billedet."        )    ));?>

Looking at the help text now - provided we shift our system language to danish - we'll see the descriptions translated into danish - except the “title” description which is missing. This description will then default to english. Notice how the additional information like “seeAlso” references and links does not need to be respecified.

In this example it is danish descriptions with the exception of the “title” which was left out in the translation.