[TYPO3-core] RFC: MM_foreign_select
Holzinger Franz
franz at fholzinger.com
Mon Jan 23 18:00:16 CET 2006
Hello René,
>A TCA config for my solution looks like this
>
>'type' => 'group',
>'internal_type' => 'db',
>'allowed' => 'tx_dam',
>'prepend_tname' => 1,
>'MM' => 'tx_dam_mm_ref',
>'MM_foreign_select' => 1,
>'MM_ident' => 'relation_field_or_other_ident',
>
>
>'MM_foreign_select' switched uid_foreign and uid_local and set tablenames to
>the local table
>
>
Please use 'uid_local' and 'uid_foreign' instead of 'MM_foreign_select'.
In your case you set:
'uid_local' => 'uid_foreign',
'uid_foreign' => 'uid_local',
'foreign_table' => 'tt_content'
This could be usefull in the future when hopefully other field names
will be allowed here. And I think this would be more easy to understand
than a multifunctional parameter doing a lot of things. At least the
field name should not be fixed but remain variable to be usable for others.
I oppose to your solution with 'MM_foreign_select'.
>'MM_ident' defines what value should be written to the "ident" field of the MM
>table. This is usually the name of the current field.
>
>
>
I think this one is only needed for DAM and nowhere else. So I suggest
you create a hook function for this. This would be helpful to others who
want to implement other functionalities with mm tables.
>$tcaFieldConf['MM_foreign_select'] = $tcaFieldConf['MM_foreign_select'] ? $table : false;
>
I think that the $TCA should not be overwritten anywhere, even if it is
a local copy.
The $TCA part $tcaFieldConf should have been passed as a reference
parameter in this function call.
>$dbAnalysis->writeMM($tcaFieldConf['MM'], $id, $prep, $tcaFieldConf['MM_ident'], $tcaFieldConf['MM_foreign_select']);
>
Please change the order of parameters so that the $tca... are one after
the other.
$id should be the first parameter.
> if (!strcmp(trim($tablelist),'*')) {
> $tablelist = implode(',',array_keys($GLOBALS['TCA']));
>+ $MMmatchTablenames = $MMmatchTablenames ? $tablelist : '';
> }
>
I cannot understand why $MMmatchTablenames is assigned the $tablelist.
You are assigning values to $matchTablenames on different places.
+ foreach($tableArr as $foreignTable) {
+ $whereArr[] = 'tablenames="'.$GLOBALS['TYPO3_DB']->quoteStr($foreignTable, $tableName).'"';
+ }
+ $where.= ' AND ( '.implode(' OR ', $whereArr).' ) ';
+ }
Is it possible to use 'WHERE tablenames IN ('table1', 'table2')' ?
Another thing:
I would like to have the $pid as a column in mm tables in order to make
them usable for the TCE. If you change the methods now: What about
adding the $pid as a parameter as well?
E.g.
function writeMM($tableName, $pid, $uid, $prependTableName=0, $ident='', $swapLocalForeign=0)
If $pid is empty: just do not use it.
$insertFields = array(
'uid_local' => $uid,
'uid_foreign' => $val['id'],
'sorting' => $c
);
if ($pid) {
$insertFields['pid'] = $pid;
}
>+ if ($ident) {
>+ $insertFields['ident'] = $ident;
>+ }
>
Here and somewhere else, as mentioned above, I would like to have the
hook function, so anybody can extend this to his needs. Instead of
$ident as a parameter use $additionalArr which will be passed to the
hook functions together with $insertFields.
Regards,
Franz
More information about the TYPO3-team-core
mailing list