[TYPO3-mvc] Filter lists with extbase (sry 4 repost, missed topic :) )
Steffen Müller
typo3 at t3node.com
Thu Jan 26 14:08:55 CET 2012
Hi Frank,
On 26.01.2012 12:38 Frank Gerards wrote:
> quick question: What would be the easiest way to do a filtered list in extbase / fluid ?
>
A good question. To whoch part of DDD/MVC does filtering beong? view?
repository?
> Put the filter criteria in the list-item model but don't persist them ?
>
One approach could be to apply the filter when fetching items from the
repository. This practice is roughly used in news extension [1]. It
ships a newsDemand Model which is a representation of the filter
options. A demand object is instanciated based on the filter options.
Fetching a subset of news from the repository is done in the list action
using:
$newsRecords = $this->newsRepository->findDemanded($demand)
However, I am not 100% sure if filter options should be represented in a
domain model. But it's a pragmatic approach: It avoids fetching all
items and filter afterwards, which does not scale and could be a
performance nightmare when you have to deal with lots of items.
> Do a helper class
>
You mean a Viewhelper? You could have a look at the pagination widget
which splits the items into separate chunks. But this IMHO has
performance drawback like mentioned before.
> Do a completely new model and new controller and insert the filter-box as a separate plugin ?
>
I don't think this is neccessary and another model/controler pair would
only add more complexity to your code.
[1] http://forge.typo3.org/projects/show/extension-news
--
cheers,
Steffen
TYPO3 Blog: http://www.t3node.com/
Twitter: @t3node - http://twitter.com/t3node
More information about the TYPO3-project-typo3v4mvc
mailing list