[TYPO3-mvc] Need a little more help to show some mm-relation info

Felix Oertel mehl at foertel.com
Fri Apr 16 01:36:16 CEST 2010


Hi Mario

Am 16.04.10 00:01, schrieb Mario Beiser:
> I can't manage it
> to show some mm-relational data in my fe-extension.

That is mainly because your model does not have an mm-relation. *g*

> Following table structure:
>
> 1. Model: person
> 2. Model: department
> MM-Relational-Table: department_person_mm
>
> Goal: Got a PersonController and print all persons in a listview.

Does this listview work? Domain_Repository_Person->findAll();

> Now I want to print the name of all departments the person belongs to
> below the name of the person.
> Model person:
>
> /**
> * @var Tx_Test_Domain_Model_Department
> * @lazy
> */
> protected $department

That's not gonna work. I think one person can be in more then one 
appartement (otherwise you would not use mm-relation). Then this has to be:

@var Tx_Extbase_Persistence_ObjectStorage<Tx_Test_Domain_Model_Department>

You can't store multiple departments in one department-object, you have 
to use an objectStorage for that.


> /**
> * Sets the department this person belongs to
> *
> * @param Tx_Test_Domain_Model_Department $department The department
> * @return void
> */
> public function setDepartment(Tx_Test_Domain_Model_Department
> $department) {
> $this->department = $department;
> }

has to be objectStorage as well ...

> TCA of Tx_Test_Domain_Model_Person:
>
> 'department' => Array (
> 'exclude' => 1,
> 'label' => 'Department', // Just example code
> 'config' => Array (
> 'type' => 'select',
> 'foreign_table' => 'tx_blogexample_domain_model_department',
> 'maxitems' => 1,
> )
> ),

this is no mm-relation. you don't use an mm-table and you use maxitems 
=> 1 (which then indicates 1:1 or n:1 relation)

> Now I added {person.department.name} in my template, but nothing is shown.

that wouldn't work with mm-relation either. person.department would be 
an objectStorage and you could iterate that with f:for-viewhelper in fluid.

> Do I have to configure anything else? ATM I just stuck a little bit.

First of all you have to decide, wether to use mm or not. If you want 
your person to be in just one department at a time, forget about 
mm-relations and -table and use n:1 relation with select and 
maxitems=>1. Otherwise you have to configure your TCA right according to 
the MM-parameter and use objectStorages.

> Perhaps someone can help me...

I hope so ;-)

regards, foertel


More information about the TYPO3-project-typo3v4mvc mailing list