[TYPO3-mvc] filter and pagination views of own extension really slow

Daniel Hirth hirth at stimme.net
Fri Apr 4 12:01:21 CEST 2014


Thanks for the tips, checking the index and declaring more object properties as lazy sped up the extension already. I still do have some questions though:

> The pagination wizard itself just sets the limit to the query and as long as
> you use "normal" queryResultObjects the request is just send once to the
> database. Maybe you can provide some code to look over to be sure none of
> you actions already fetches whole objects.

Okay, so in the action, I just call the repository function and deliver the results to the view. 

public function listAction($filter) {
    // [...]
    $events = $this->eventRepository->findByFilter($filter);
    $this->view->assign('filter', $filter);
}

In the view, the event Items are counted before they are paginated, could this be a problem? 

<f:if condition="{events}">
    <f:then>
        <f:if condition="{settings.itemsPerPage}">
            <f:then>
                <f:if condition="{events->f:count()} >= {settings.itemsPerPage}">
                    <f:then>
                        <f:widget.paginate objects="{events}" as="pageevents">
                            <f:for each="{pageevents}" as="event">
                                <f:render partial="Event/EventItem" arguments="{event:event}" />
                            </f:for>
                        </f:widget.paginate>
                    </f:then>
                    <f:else>
                        <f:for each="{events}" as="event">
                            <f:render partial="Event/EventItem" arguments="{event:event}" />
                        </f:for>
                    </f:else>
                </f:if>
            </f:then>
        </f:if>
    </f:then>
    <!-- [...] -->
</f:if>

> 1) don use noCache, with noCache in your Request you dont use any caches
> use a separat action that is uncached, for example results. 
> Then you can display lists (cached) or result-views (uncached)

I created a new action "listResults", which is basically a copy of the list action, and set it to non-cacheable in the localconf. For the templates of both the list action and the listResults action the same two partials are called: 

<f:render partial="Event/EventFilter" arguments="{filter:filter}" />
<f:render partial="Event/EventList" arguments="{events:events}" />

The filter form was changed like this: 

<f:form object="{filter}" name="filter" method="post" action="listResults">
    <!-- [...] -->
</f:form>

So when a visitor uses the filter form he will be redirected to the listResults action, which is not cached. This works, EXCEPT that the filter object is lost in the listResults-Action, even though the Post-data is clearly transferred between the actions. Is this because i chose to use a filter object instead of an array?

Thanks and best regards
Daniel


More information about the TYPO3-project-typo3v4mvc mailing list