[TYPO3-mvc] How to implement a selectfield/SPLobjectArray containing different object types?

Jochen Rau jochen.rau at typoplanet.de
Thu Jan 7 10:52:00 CET 2010


Hi Franz,

sorry for the late reply. I hope It's not too late.

On 29.12.09 15:54, Franz Koch wrote:
>> My problem is now, that there are not only articles that can be assigned
>> to a page, but also other content elements (like article-sets and in
>> future probably more). And now I don't know how I should handle this. My
>> idea was now to add a property "content" (type array?) to my page
>> objects and let it contain any of the needed content elements - so
>> speaking in TCEforms a group-field where different tables are allowed to
>> be selected.
>>
>> But how to correctly implement this in the extBase way? Should I add a
>> method "getContentElements" to my page model and do all the magic there
>> by calling a repository (which one to use btw - a pageRepository with a
>> according method?).
>> Or should I better use a dedicated SPLobjectArray for each contentType?
>
> I'm still struggling with this last problem I've got in the concept
> phase of my db-scheme/model. I need a way to assign various content
> types to my page models, where "content types" are not like in TYPO3
> based on a single table, so no single table inheritance, but can be
> selected from different tables. So just like in the TYPO3 content
> element "insert records", where you can select tt_content, tt_news, etc.
>
> Is extbase up to this? And if so, how to do? Just by setting up the TCA
> accordingly? But how to map classes to those records then? Or can
> someone point me to the correct documentation? I can't read the stuff in
> the extension doc_extbase (don't have a docbook reader - still
> searching) and the api-reference in there didn't help.

I would implement a property $contentElement in your Page domain model 
holding the content objects in an ObjectStorage. All content objects 
should implement a common Interface like 
TX_MyExt_Domain_Model_ContentInterface.

Atm it is not possible to fill this ObjectStorage automatically (because 
of the lack of single table inheritance). You have to do this manually. 
You might also define an Object-Table-mapping (see 
EXT:extbase/Configuration/TypoScript/setup.txt.

There is a related article on the FLOW3 mailing list that might help 
(not a solution for your problem, but it points you in the right direction).

Newsgroups: flow3.general
Subject: [FLOW3-general] Storing/Receiving Different Models with one Action
Date: Wed, 23 Dec 2009 14:29:36 +0100
Message-ID: <mailman.12731.1261575062.615.flow3-general at lists.typo3.org>

The type can be selected via the BE as you described.

I'm not sure if I got the point. Don't hesitate to ask again.

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list