Display list of elements grouped by year and by month in TYPO3 Fluid

前端 未结 3 1793
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 04:49

I have a model where one field is a date. I want to display elements from that model, grouped by year and by month, like this:

== 2013 ==
=== April ===
* Ele         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 05:18

    First you need to iterate your resultset in the controller, save it into array, and make sure that every row has extracted date to separate indexes for year and month.

    In such case you'll be able to use view helper.

    Other option is adding these fields (year and month) to your model and setting proper values while saving/updating the object. Using this approach you'll avoid the need of the controller's iteration mentioned above, buuuutttt... if you are going to access these records with common TYPO3's backend, you will need to use some postprocess hooks to set these fields after database operations.

提交回复
热议问题