When you create a new content element by using the record wizard, you'll get a tab-based list of possible content elements to choose from. In the old days, those were PHP classes known as "wizicons" and automatically created by the kickstarter extension. You may guessed it already, it's about $GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses']
.
This approach is not deprecated yet, but discouraged within the TYPO3 Core, as non of the shipped extensions use this mechanism.
As exception of the rule, EXT:indexed_search
still uses this approach, in case EXT:compatibility7
is installed.
In this article we're going to migrate the PHP-based classes to plain TypoScript. As example extension we use tt_news 7.6.3.
In its ext_tables.php
you may find the following code:
$TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']['tx_ttnews_wizicon'] = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'pi/class.tx_ttnews_wizicon.php';
The registered class itself has a method called proc()
that basically modifies an array only:
function proc($wizardItems) {
// ...
$wizardItems['plugins_tx_ttnews_pi'] = array(
'icon'=>TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('tt_news').'pi/ce_wiz.gif',
'title'=>$LANG->getLLL('pi_title',$LL),
'description'=>$LANG->getLLL('pi_plus_wiz_description',$LL),
'params'=>'&defVals[tt_content][CType]=list&defVals[tt_content][list_type]=9'
);
return $wizardItems;
}
Migrating this to TypoScript is a rather easy task. For beginning, a new file called Configuration/PageTS/NewContentElementWizard.ts
is created within the extension directory:
mod.wizards {
newContentElement.wizardItems {
plugins {
elements {
plugins_tx_ttnews_pi {
icon = EXT:tt_news/pi/ce_wiz.gif
title = LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:tt_news_title
description = LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:tt_news_description
tt_content_defValues {
CType = list
list_type = 9
}
}
}
}
}
}
You probably noticed that the structure of the TypoScript is nearly the same as the PHP-based array, but there are a few minor differences:
EXT:
, TYPO3 resolves this automaticallyparams
key is replaced by tt_content_defValues
Very important is that the configuration is wrapped within this scaffold, otherwise the TS won't work:
mod.wizards {
newContentElement.wizardItems {
plugins {
elements {
// YOUR CODE
}
}
}
}
Now, the TypoScript file must be registered. This is done within ext_localconf.php
, NOT ext_tables.php
(everytime you do this a unicorn dies, now do the math 😉):
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:tt_news/Configuration/PageTS/NewContentElementWizard.ts">'
);
We're nearly done. The last thing we have to do is removing any evidence of the old PHP-based approach. Means, you should remove the registration based on $GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses']
and clear the TYPO3 caches afterwards. If everything still works fine, it's sav to remove the wizicon PHP class.