[TYPO3-dev] Symmetric bidirectional MM ralations on the same table

Steffen Müller typo3 at t3node.com
Mon Jul 27 15:09:48 CEST 2009


Hi.

My entity 'article' should be allowed to have references to records of
the same entity (table).
I tried to add a column 'related' of type 'select' which makes use of a
MM-table. But I can only see the reference in one way (in the article
where I added the reference). The article which was added as a reference
does not show the reference to its origin.

What I tried was:

ext_tables.sql
----------------------------------------------------
CREATE TABLE tx_myext_article (
...
related int(11) DEFAULT '0' NOT NULL,
)

CREATE TABLE tx_myext_article_relations_mm (
  uid_local int(11) unsigned DEFAULT '0' NOT NULL,
  uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
  sorting int(11) unsigned DEFAULT '0' NOT NULL,
  sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
  tablenames varchar(64),
)

tca.php:
---------------------------------------------------------
$TCA['tx_cok_domain_model_article'] = array(
  'columns' => array(
    'relatedarticle' => array(
      'label' => 'Related articles',
      'config' => array(
        'type' => 'select',
        'foreign_table' => 'tx_myext_article',
        'foreign_table_where' => 'AND
tx_myext_article.uid!=###THIS_UID### ORDER BY tx_myext_article.title',
        'size' => 8,
        'minitems' => 0,
        'maxitems' => 64,
        'MM' => 'tx_myext_article_relations_mm',
        'MM_match_fields' => array(
          'tablenames' => 'tx_myext_article'
        ),
      ),
    ),
  ),
);

With two entities, this kind of relation is possible.

inline/irre is not an option here because it seems to be too bloated.

-- 
cheers,
Steffen

TYPO3 Blog: http://www.t3node.com/
Blubber on Twitter: http://twitter.com/t3node




More information about the TYPO3-dev mailing list