There is a simple table of news articles: [ id | title | body | created ].
What is the best way to create a simple news archive using smarty from a full collection of articles ordered by created date?
In the format:
- 2009
- 12.11. Title
- 03.03. Title
- 01.01. Title
- 2008
- 11.12. Title
- 04.03. Title
- 02.03. Title
- 16.02. Title
- 2007
- …
- …
<ul>
{foreach item=p from=$news}
<li>{$p->created} {$p->title}</li>
{/foreach}
</ul>
There are 2 ways
The first would go
The other one is to group the values in php:
The choice is up to you