我无法更改传递给 Smarty 的数组,尽管目前我有:
{if $cms.featured && $cms.featured.haspictures}
{foreach from=$cms.featured.pictures key=id item=row name=foo}
{if $id eq 0}
<div class="sliderkit-panel">
<a href="{$cms.featured.url}" title="{$cms.featured.title|truncate:60}"><img src="{$HOME}/get/wide{$row.filename}" alt="{if $row.description}{$row.description}{else}{$cms.featured.title}{/if}" /></a>
</div>
{/if}
{/foreach}
{/if}
{if $cms.featured1 && $cms.featured1.haspictures}
{foreach from=$cms.featured1.pictures key=id item=row name=foo}
{if $id eq 0}
<div class="sliderkit-panel">
<a href="{$cms.featured1.url}" title="{$cms.featured1.title|truncate:60}"><img src="{$HOME}/get/wide{$row.filename}" alt="{if $row.description}{$row.description}{else}{$cms.featured1.title}{/if}" /></a>
</div>
{/if}
{/foreach}
{/if}
{if $cms.featured2 && $cms.featured2.haspictures}
{foreach from=$cms.featured2.pictures key=id item=row name=foo}
{if $id eq 0}
<div class="sliderkit-panel">
<a href="{$cms.featured2.url}" title="{$cms.featured2.title|truncate:60}"><img src="{$HOME}/get/wide{$row.filename}" alt="{if $row.description}{$row.description}{else}{$cms.featured2.title}{/if}" /></a>
</div>
{/if}
{/foreach}
{/if}
无论如何我可以减少这个重复的代码吗?