[TYPO3-mvc] Bidirectional relations

Christian Zenker christian.zenker at 599media.de
Mon Jul 20 10:18:41 CEST 2009


Am 19.07.2009, 16:05 Uhr, schrieb Tobias Pinnekamp <typo3 at tpinne.de>:


> I only have a problem implementing my datastructure because I need  
> bidirectional relations between tables. For 1:n and for m:n relations.  
> But I only figured out how to configure one direction. Got this from the  
> blog_example.

Something like that should work, if you use the latest version from svn  
(the TYPO3 4.3alpha release version doesn't to work -> see my question a  
few days ago):

//TCA for 'post'
'tag' => array (	
	'label' => 'related tags',		
	'config' => array (
		'type' => 'select',		
		'foreign_table' => 'tx_blogexample_domain_model_tag',
		'foreign_class' => 'Tx_BlogExample_Domain_Model_Tag',
		'size' => 5,	
		'minitems' => 0,
		'maxitems' => 5,
		'MM' => 'tx_blogexample_post_tag_mm',
	)
)

//TCA for 'tag'
'blog' => array (	
	'label' => 'related posts',		
	'config' => array (
		'type' => 'select',	
		"foreign_table" => "tx_blogexample_domain_model_post",
		'foreign_class' => 'Tx_BlogExample_Domain_Model_Post',
		'size' => 5,	
		'minitems' => 0,
		'maxitems' => 10,
		'MM' => 'tx_blogexample_post_tag_mm',
		'MM_opposite_field' => 'tag'
	)
)

Christian


More information about the TYPO3-project-typo3v4mvc mailing list