How to generate year in Smarty?

streetparade picture streetparade · Feb 16, 2010 · Viewed 8.3k times · Source

How can i generate a select list with the given year till this year? i did this

{assign var=thisyear value=$smarty.now|date_format:"%Y"}
{if !$firstyear}
 {assign var=firstyear value="2003"}
{/if}

{if !$loop}{assign var=loop value=$thisyear}{/if}
<select name='{$id|default:year}' id={$id|default:year} style='width:70px;'>

 {section name=yearValue max=$year start=$firstyear loop=$thisyear step=-1}
  <option{if $year==$smarty.section.yearValue.index} selected="selected"{/if}>{$smarty.section.yearValue.index}</option>
 {/section}

</select>

unfotunatly this produces 0 till 2003 but i want that it generates 2003 till 2010 how can i do that?

Answer

Htbaa picture Htbaa · Feb 16, 2010

Have a look at html_select_date