[TYPO3-mvc] Get content elements from a page model
Franz Koch
typo3.RemoveForMessage at elements-net.de
Tue Jan 18 10:42:33 CET 2011
Hey,
>> I've ceated my own Tx_MyExt_Domain_Model_Typo3_Page model and
>> as there is no separate field like 'content' in the table 'pages',
>> I was wondering how to get all related recods from 'tt_content'?
>>
>> I see 2 possible solutions:
>>
>> 1.) Just define a getter and setter inside the page model and
>> implement it manually using a 'tt_content' repository or
>>
>> 2.) Add a new field in the database which could be used by
>> Extbase to populate the new property automatically.
>>
>> Not sure what would be the best way so, any ideas?
>> What's the better solution or are there any better ones?
>
> I think that depends on your usecase. If you intend to use it to render
> your website you most likely need to differ between different content
> columns and thus using getters triggering a repository or service would
> make more sense to me. If it's just for managing/displaying any content
> records a db-field would also be ok for me - but I'd probably stick with
> dummy getters/setters and triggering a service/repository there.
After thinking about it again, I'm not sure anymore. As for the
rendering of specific columns, using viewHelpers that filter the content
elements seem to be a much cleaner solution, because you don't have to
manipulate your page model to add new getters/setters as soon as you add
another content column. So probably add one getter/setter pair
triggering a contentRepository->findByPage($this), or extend the TCA/DB.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list