This is an old question and already has an accepted answer, but the answer was basically just a link. I have posted this as a more complete answer, to avoid future visitors having to trawl the docs to find the relevant example.
In Smarty 2, loops are achieved using the {section}
tag, which covers quite a broad range of use-cases. To write the equivalent of a PHP for()
loop, the following syntax is used:
<select>
{section name="i" start=1950 loop=2001}
<option value="{$smarty.section.i.index}">{$smarty.section.i.index}</option>
{/section}
</select>
Note that the loop
property refers to the number at which Smarty will break out of the loop, so it needs to be 1 higher than the final number you want to iterate over.
ADDENDUM:
Although this is not directly relevant to the question (which is about Smarty 2), it is worth noting that Smarty 3 introduced a {for}
tag, so you can now do the following, which is a lot simpler:
<select>
{for $i=1950 to 2000}
<option value="{$i}">{$i}</option>
{/for}
</select>