[TYPO3-mvc] Fluid ViewHelper Incubator
Bastian Waidelich
bastian at typo3.org
Fri Jan 7 17:34:06 CET 2011
Simon Schaufelberger wrote:
Hi Simon,
> what i cannot do is to take that min, max, avg and do something with it
> in my model or controller since there is none ;) so i need to do all the
> calculations in the fluid template.
IMO whenever you're tempted to do calculations or extensive grouping
within your template, you should think about an intermediate model that
encapsulates that aggregate functionality.
E.g. if you think about a shop: you wouldn't want to iterate through the
articles and calculate the total in your view. Instead you might create
a "Basket" model that contains the articles and can do those
calculations for you.
> example: i calculate the max time of all items in the list in my
> typoscript and then assign it to the view. in the view i want to
> multiply the time with a price that comes from another column.
The same here: Just create an object that matches your domain and assign
*that* to your view. Even if the domain in your case is very flexible,
it's the better approach in my opinion.
Sometimes it's probably still the faster or pragmatic way to do some
calculations in the template.. But in that case you're free to install
the incubator extension or provide the needed view helpers with your
extension. don't you think?
Best,
Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list