[TYPO3-core] RFC: Bidirectioanl MM relations

Franz Holzinger franz at fholzinger.com
Wed Sep 6 17:39:14 CEST 2006


Hello Ingmar,


> This is a SVN patch request.
> 
> Problem:
> Currently you can edit mm-relations in the Backend from one side of
the
> relation only.
> 
> Solution:
> We (Sebastian and me) made it possible to configure the same relation
> from both sides exactly the same way. There is only one difference
> between the configuration on the "foreign" side of the relation
compared
> to the configuration on the "local" side (You still need to decide
which
> side you want to call "local", even though there is no longer a real
> difference between the "local" and "foreign" side): The foreign-side
> needs to have the following defined in TCA:
>     "MM_opposite_field" => 'employees',
> 
> Here's an example configuration:
> 

>     $TCA["persons"] = Array (
>         [...]
>         "columns" => Array (
>             [...]
>             "employers" => Array (
>                 "exclude" => 1,
>                 "label" => "Employers",
>                 "config" => Array (
>                     "type" => "select",
>                     "foreign_table" => "companies",
>                     "size" => 5,
>                     "MM" => "companies_employees_mm",
> 
>                         // New:
>                     "MM_opposite_field" => 'employees',
>                 )
>             )
>         )
>     );

I have another proposal instead of the 'MM_opposite_field'.

Have a look at the feature request
http://bugs.typo3.org/view.php?id=2822 to make mm tables usable like
normal tables with TCE.

Use 'MM_key' => 'uid_foreign'.
This would be flexible enough to extend this later to 'MM_key' => 'uid1,
uid2' to have more fields or use other names than 'uid_local' and
'uid_foreign' which form the key.



$TCA['companies_employees_mm'] = Array (
        'ctrl' => Array (
                'title' =>
'LLL:EXT:myext/locallang_db.php:companies_employees_mm',
## WOP:[tables][1][title]
                'label' => 'title',     ## WOP:[tables][1][header_field]
                'tstamp' => 'tstamp',
                'crdate' => 'crdate',
                'cruser_id' => 'cruser_id',
                'key' => 'uid_local,uid_foreign',
                'sortby' => 'sorting',  ## WOP:[tables][1][sorting]
                'delete' => 'deleted',  ## WOP:[tables][1][add_deleted]
                'enablecolumns' => Array (              ##
WOP:[tables][1][add_hidden] /
[tables][1][add_starttime] / [tables][1][add_endtime] /
[tables][1][add_access]
                        'disabled' => 'hidden', ##
WOP:[tables][1][add_hidden]
                        'starttime' => 'starttime',     ##
WOP:[tables][1][add_starttime]
                        'endtime' => 'endtime', ##
WOP:[tables][1][add_endtime]
                        'fe_group' => 'fe_group',       ##
WOP:[tables][1][add_access]
                ),
                'dynamicConfigFile' =>
t3lib_extMgm::extPath($_EXTKEY).'tca.php',
                'iconfile' =>
t3lib_extMgm::extRelPath($_EXTKEY).'icon_companies_employees_mm.gif',
        ),
        'feInterface' => Array (
                'fe_admin_fieldList' => 'hidden, starttime, endtime,
fe_group,
mm_attribute1, mm_attribute2',
        )
);




I think the sorting should be extended in a way usable for all tables.
It could be usefull to have more than one sorting for one table. So the
sorting could be done on some other attributes and e.g. 10 sorting
fields if someones would need that.

    CREATE TABLE companies_employees_mm (
        uid_local int(11) DEFAULT '0' NOT NULL,
        uid_foreign int(11) DEFAULT '0' NOT NULL,
        tablenames varchar(30) DEFAULT '' NOT NULL,
        sorting int(11) DEFAULT '0' NOT NULL,

            # New:
        sorting2 int(11) DEFAULT '0' NOT NULL,
        sorting3 int(11) DEFAULT '0' NOT NULL,
.
.
.
        sorting10 int(11) DEFAULT '0' NOT NULL,

        KEY uid_local (uid_local),
        KEY uid_foreign (uid_foreign)
    );


I would like to have this modified to get rid of fixed field names
'uid_local' and 'uid_foreign' and to have a TCA for mm tables.

If we would introduce a $TCA['companies_employees_mm'] now, then it also
became possible to add a new column here, which defined the table for
uid_local and the table for uid_foreign e.g. 'local_table',
'foreign_table'. This would be necessary to get the feature request of
editable mm tables done. 


Greets,

Franz


P.S: I would also like to get rid of the necessity to have a 'pid' field
for all tables. This is to be able to use any sql table from some PHP
code unmodified.









More information about the TYPO3-team-core mailing list