[TYPO3-dev] Replacing/exchanging a field if a specific extension is loaded
Stefan Geith
typo3dev2010.nospam1 at geithware.de
Tue Jun 15 12:30:30 CEST 2010
Hi Thasmo,
Thomas "Thasmo" Deinhamer schrieb:
> Imagine there's a TCA field 'author varchar(255)' where someone could
> enter the author's name. But now if e.g. tt_address is installed, it
> would be cooler to have a 'select' field to choose an address/contact from.
>
> How could I solve this the best way?
>
> The main concern I have, is about the SQL definition and the naming of
> the field. Should I call the field 'author_name' if the extension is not
> installed and call it 'author' if it IS installed?
1. I think you should always have the default-field 'author_name'
and a field 'author' that can hold the reference to an address-field
2. In TCA.php you can check if address-extension is enabled
an decide, whether field 'author_name' or field 'author'
is included to the fieldlist of the types-Array.
BUT: both fields must be defined in the columns-array
of TCA.
3. In my extension, I use 'ext_conf_template.txt' to define the
extensionname and the tablename for such references.
Then I let the user decide to use 'tt_address' or 'sg_address'
or his own address-extension or even none ...
In TCA I do this by e.g.
$confVars = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['xyz']);
...
'author' => Array (
...
'config' => Array (
'type' => 'group',
'internal_type' => 'db',
'allowed' => $confVars['myAddressTable'],
Hope this helps ...
/Stefan
More information about the TYPO3-dev
mailing list