Attention

TYPO3 v8 has reached its end-of-life March 31st, 2020 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

There is no further ELTS support. It is recommended that you upgrade your project and use a supported version of TYPO3.

Implementing CSH

For new tables and fields

Create a language file following the explanations given in this chapter and register it in your extension's ext_tables.php file:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
        'tx_domain_model_foo',
        'EXT:myext/Resources/Private/Language/locallang_csh_tx_domain_model_foo.xlf'
);

The rest of the work is automatically handled by the TYPO3 CMS form engine.

Adding CSH for fields added to existing tables

Create a language file in your extension using the name of the table that you are extending. Inside the file, place labels only for the fields that you have added. Register the file as usual, but for the table that you are extending:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
        'pages',
        'EXT:myext/Resources/Private/Language/locallang_csh_pages.xlf'
);

The example assumes that you are extending the "pages" table.

For modules

Implementing CSH for your backend module requires a bit more work, because you don't have the form engine doing everything for you.

The start of the process is the same: create your language file and register it.

The main method that renders a help button is \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem(). This renders the question mark icon and the necessary markup for the JavaScript that takes care of the tool tip display. To make the markup into a button some wrapping must be added around it:

<span class="btn btn-sm btn-default">(CSH markup)</span>

For adding a help button in the menu bar, the following code can be used in the controller:

/**
 * Registers the Icons into the docheader
 *
 * @return void
 * @throws \InvalidArgumentException
 */
protected function registerDocHeaderButtons()
{
    /** @var ButtonBar $buttonBar */
    $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();

    // CSH
    $cshButton = $buttonBar->makeHelpButton()
        ->setModuleName('xMOD_csh_corebe')
        ->setFieldName('filelist_module');
    $buttonBar->addButton($cshButton);
}

This code is taken from class \TYPO3\CMS\Filelist\Controller\FileListController and takes care about adding the help button on the right-hand side of the module's docheader. The argument passed to setModuleName() is the key with which the CSH file was registered, the one passe to setFieldName is whatever field name is used in the file.

To place a help button at some arbitrary location in your module, you can rely on a Fluid view helper (which - again - needs some wrapping to create a true button):

<span class="btn btn-sm btn-default">
        <f:be.buttons.csh table="xMOD_csh_corebe" field="filelist_module" />
</span>

This example uses the same arguments as above.