[TYPO3-core] TCA Wizard add variables
Steffen Kamper
info at sk-typo3.de
Sat May 31 13:17:05 CEST 2014
Hi,
with the wish of organizing related records in the BE i stumbled on this kind of configuration:
'competition' => array(
'exclude' => 0,
'label' => 'LLL:EXT:ceb_dates/locallang_db.xml:tx_cebdates_dates.competition',
'config' => array(
'type' => 'select',
'foreign_table' => 'tx_ceb_competition',
'foreign_table_where' => ' AND tx_ceb_competition.pid = ###PAGE_TSCONFIG_ID### ORDER BY tx_ceb_competition.uid',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
'wizards' => array(
'_PADDING' => 2,
'_VERTICAL' => 1,
'add' => array(
'type' => 'script',
'title' => 'Create new record',
'icon' => 'add.gif',
'params' => array(
'table' => 'tx_ceb_competition',
'pid' => '###PAGE_TSCONFIG_ID###',
'setValue' => 'prepend'
),
'script' => 'wizard_add.php',
),
),
)
),
Though the variable ###PAGE_TSCONFIG_ID### is replaced correctly in the where part of selecting recorrds, it doesn't work with adding new records with the wizard.
Looking to the code, i found the reason:
if (substr($this->P['params']['pid'],0,3)=='###' && substr($this->P['params']['pid'],-3)=='###') {
$this->pid = intval($TSconfig['_'.substr($this->P['params']['pid'],3,-3)]);
where only available vars here are CURRENT_PID, STORAGE_PID and SITEROOT, though documentation promises more :)
I was able to fix it by inserting this small logic:
// Set [params][pid]
if (substr($this->P['params']['pid'],0,3)=='###' && substr($this->P['params']['pid'],-3)=='###') {
$keyword = substr($this->P['params']['pid'], 3, -3);
if (substr($keyword, 0, 14) == 'PAGE_TSCONFIG_') {
$this->pid = intval($TSconfig[$this->P['field']][$keyword]);
} else {
$this->pid = intval($TSconfig['_' . $keyword]);
}
} else $this->pid = intval($this->P['params']['pid']);
Maybe someone wants to pick it up for integration.
Thanks.
More information about the TYPO3-team-core
mailing list