Rotten, сравнивайте:
1. Smarty
{if $photos}
<table border="0" align="center" width="100%">
<tr>
{assign var="i" value="0"}
{foreach from=$photos item="v"}
{if $i lt 3}
<td align="center">
<a href="/photo/{$v.id}">
<img src="/preview/{$v.id}" border="0" alt="{$v.title}">
</a> <br />
<a href="/photo/{$v.id}"> {$v.title} </a>
</td>
{assign var="i" value=$i+1}
{else}
</tr>
<tr>
<td align="center">
<a href="/photo/{$v.id}">
<img src="/preview/{$v.id}" border="0" alt="{$v.title}">
</a> <br />
<a href="/photo/{$v.id}"> {$v.title} </a>
</td>
{assign var="i" value="1"}
{/if}
{/foreach}
</table>
{/if}
2. Нативные:
<?if ($this->photos):?>
<table border="0" align="center" width="100%">
<?for ($j = 0; $j < count ($this->photos); $j+=3):?>
<tr>
<?for ($i = j; $i < j + 3; $i++):?>
<td align="center">
<a href="/photo/<?=$this->photos[$i]['id']?>">
<img src="/preview/<?=$this->photos[$i]['id']?>"
border="0" alt="<?=$this->photos[$i]['title']?>">
</a> <br />
<a href="/photo/<?=$this->photos[$i]['id']?>">
<?=$this->photos[$i]['title']?> </a>
</td>
<?endfor?>
</tr>
<?endfor?>
</table>
<?endif?>
3. На закуску — откомпилированный Smarty:
<?php if ($this->_tpl_vars['photos']): ?>
<table border="0" align="center" width="100%">
<tr>
<?php echo smarty_function_assign
(array('var' => 'i','value' => '0'), $this);?>
<?php if (count($_from = (array)$this->_tpl_vars['photos'])):
foreach ($_from as $this->_tpl_vars['v']):
?>
<?php if ($this->_tpl_vars['i'] < 3): ?>
<td align="center">
<a href="/photo/
<?php echo $this->_tpl_vars['v']['id']; ?>
">
<img src="/preview/
<?php echo $this->_tpl_vars['v']['id']; ?>
" border="0" alt="<?php echo $this->_tpl_vars['v']['title']; ?>
">
</a> <br />
<a href="/photo/
<?php echo $this->_tpl_vars['v']['id']; ?>
"> <?php echo $this->_tpl_vars['v']['title']; ?>
</a>
</td>
<?php echo smarty_function_assign
(array('var' => 'i',
'value' => $this->_tpl_vars['i']+1), $this);?>
<?php else: ?>
</tr>
<tr>
<td align="center">
<a href="/photo/
<?php echo $this->_tpl_vars['v']['id']; ?>
">
<img src="/preview/
<?php echo $this->_tpl_vars['v']['id']; ?>
" border="0" alt="<?php echo $this->_tpl_vars['v']['title']; ?>
">
</a> <br />
<a href="/photo/
<?php echo $this->_tpl_vars['v']['id']; ?>
"> <?php echo $this->_tpl_vars['v']['title']; ?>
</a>
</td>
<?php echo smarty_function_assign
(array('var' => 'i',
'value' => '1'), $this);?>
<?php endif; ?>
<?php endforeach; unset($_from); endif; ?>
</table>
Подробнее на эту тему:
http://s-a-p.in/interactive/theme/about-templates-part-onehttp://s-a-p.in/interactive/theme/about-templates-part-two