How to display news articles grouped by year with

2019-09-11 13:34发布

问题:

I tried to show a list of news articles with the LIST-Modul grouped by year. The year itself should be displayed as headline for each group of articles. Like

2014
--------
article 1
article 2
article 3
--------
2013
--------
article 4
article 5
...

I tried to implement it with the f:groupedFor viewhelper in the standard list.html template of the extension. inside the pagedNews part. But TYPO3 throws the exception: http://wiki.typo3.org/Exception/CMS/1237900529

I also tried the viewhelper mentioned here: https://gist.github.com/daKmoR/1287203 and read the question here Display list of elements grouped by year and by month in TYPO3 Fluid

Both seams not to work inside news templates

回答1:

I finally got the viewhelper to work.

Here is my little extension based on https://gist.github.com/daKmoR/1287203

https://github.com/unconnect/news_grouped_by_date

With this I was able to group news by year.