[TYPO3-mvc] Best practice: where to prepare a model property and how to iterate

Gerhard Mehsel sparking at gmx.net
Mon Jul 19 10:52:38 CEST 2010


Hello,

I'm just coding my first extbase/fluid extension and have a question how 
to achieve the following at a good/extbase way.

A user creates a database record in BE where he has to select a date. 
Afterwards in FE this date is used to categorize the database records.

An example:
The user creates three database records with the three dates: 
2010-07-12, 2010-06-11 and 2011-01-12.

Now in FE view I want to render two main tabs named "2010" and "2011", 
first with two subtabs named "07" and "06" and the second with one 
subtab named "01".

In my fluid template I iterate over the DB record objects. And these 
objects have one property "date" but I need to split that dates into 
year and month to get the information for tabs and subtabs.

_Where_ to put that date-split stuff? I think I have to code some 
getYear(), getMonth() methods in my model. Is that the correct position? 
Or do I do that in controller or in fluid template?



Another question: I fetch the above list of DB records within the 
list-controller and a repository method findAll(). Now I have a flat 
list of objects. How and where should I prepare the object list so that 
I can render my tabs and subtabs, because they have to be nested 
correctly. Pseudo code to clarify what I mean:
<div class="tab_uid1"><h1>2010</h1>
   <div class="subtab_uid1">07</div>
   <div class="subtab_uid2">06</div>
</div>
<!-- now I have to repeat the stuff to get next tab -->
<div class="tab_uid2"><h1>2011</h1>
   <div class="subtab_uid1">01</div>
</div>
....

Can or should this be done in fluid or should I first prepare a new 
object array in a helper class like
array("2010" => array("07","06"), "2011" => array("01"))
to iterate over the objects?



Thank you for tips,
Gerd


More information about the TYPO3-project-typo3v4mvc mailing list