[TYPO3-mvc] get records from own model pages

Georg Schönweger georg.schoenweger at gmail.com
Wed May 4 17:01:23 CEST 2011


Hi Franz,

thank you for your tips! I did it now with solution a), the repository
calls i swaped in a service class. Thats just great because in my case i
have 2 times the same plugin on 1 page. Now with my singleton service
class where i fetch records from DB and cache them in a private
property, the cache should be valid for the 2 plugins :)

I develope now for quite a long time extensions the old pibase way. It's
a little bit tricky to get into the Extbase concepts and it takes some
time, but now i see that this is a very cool project! Developing with
Extbase / Fluid / Flow3 it's just great! Thank you

- Georg
 

Am 03.05.2011 19:28, schrieb Franz Koch:
> Hey Georg,
>
> ...
>> a) i could create in the page model a function getRecords where i create
>> an instance of the records repository and return all records with
>> pid=$this->pid
>> b) Iterate in the controller trough all pages. In the loop i call find
>> Method of the records-repository and do something like
>> pages->setRecords(foundRecords) (not sure if i have access to the model
>> via the repository)
>
> I think both would be fine if they fit your needs, whereas a) is in my
> eyes the cleaner approach. Don't forget to "cache" the records inside
> your page model (using a private property) so that you don't have to
> query the repository over and over again if getRecords is triggered
> several times (like first in a if-VH and then for rendering).
>
>> .. i could also create a new field in pages table with relation to the
>> records but i don't want this because i have the relation already via
>> the pid field of records ..
>
> That would of course be the cleanest solution, but as you mentioned
> you'd need a extra DB field on the pages table which you don't want to
> add - so I'd use approach a). The only thing you could think about
> with solution a) is, that instead of messing around with a repository
> inside a model, it might be a bit nicer to move the repository calls
> (and probably also the caching logic) to a service and just call the
> service method from within your page models (doing so don't forget to
> declare your service as singleton for this use case).
>


More information about the TYPO3-project-typo3v4mvc mailing list