{** * Article archive, content template * Date: 17.06.08 * * @package saurus4 * * @author Saurus * *} {* year and month to display *} {if $smarty.get.year} {assign var="year" value=$smarty.get.year|@intval} {else} {assign var="year" value=$smarty.now|date_format:"%Y"} {/if} {if $smarty.get.month} {assign var="month" value=$smarty.get.month|@intval} {else} {assign var="month" value=$smarty.now|date_format:"%m"|regex_replace:"/^0/":""} {/if} {* / year and month to display *}
{* list of years, only the ones containing articles *} {init_objects name="years" select="year(aeg) as y" where="year(aeg) BETWEEN 1 AND 2998" order="y" group="y" classes="article"} {assign var="act_years" value="0"} {foreach from=$years item="obj" name="years" key="year_key"} {$act_years|@array_push:$obj->all.y} {/foreach} {if !in_array($year, $act_years)}{assign var="year" value=$act_years[$year_key]}{/if}

{foreach from=$years item="obj" name="years"} {if $obj->all.y != $year}{else}{/if}{$obj->all.y}{if $obj->all.y != $year}{else}{/if} {/foreach}

{* /list of years, only the ones contaning articles *} {* create array of month numbers containing articles *} {init_objects name="months" select="year(aeg) as y, month(aeg) as m" where="year(aeg) = `$year`" order="m" group="m" classes="article"} {assign var="act_months" value="0"} {foreach from=$months item="obj" key="month_key"} {$act_months|@array_push:$obj->all.m} {/foreach} {if !in_array($month, $act_months)}{assign var="month" value=$act_months[$month_key]}{/if} {* /create array of month numbers containing articles *} {* all the months in a year *}

{section name="all_months" loop="13" start="1"} {if in_array($smarty.section.all_months.iteration, $act_months) && $smarty.section.all_months.iteration != $month}{else}{/if}{if $smarty.section.all_months.iteration == $month}{/if}{$smarty.section.all_months.iteration}{if $smarty.section.all_months.iteration == $month}{/if}{if in_array($smarty.section.all_months.iteration, $act_months) && $smarty.section.all_months.iteration != $month}{/if} {/section}

{* /all the months in a year *} {* the article list *} {init_articles name="articles" where="year(aeg) = `$year` and month(aeg) = `$month`" order="date desc" buttons="new,edit,hide,delete"} {foreach from=$articles item="article"}

{$article->date} {$article->buttons} {$article->title} {if $article->comment_count}({$article->comment_count}){/if}

{/foreach} {* /the article list *}