Smarty - 在foreach列表中添加html标记

时间:2013-04-21 18:39:58

标签: php

我有一个加密的脚本,我无法修改PHP文件,只能修改HTML模板文件,我正在尝试修改某些页面。

我想要做的是使用某些类别填充列表,但在一定数量的类别之后我想添加HTML标记。我在管理面板中有此选项,但视频不适用于类别。对于视频我有这个代码:

            {foreach from=$array_recently_added_videos item=video name=videos}
<div class="video">
html code here..
</div>

        {if ($smarty.foreach.videos.index+1)%$aSettings.videos_cols==0}<br class="clear">{/if}
        {foreachelse}
          <center><br><b>No videos where found.</b><br></center>
        {/foreach}

因此,如果我在管理面板中设置5列视频。在5个视频之后,它会广告这段HTML代码

<br class="clear">

我想对类别做同样的事情。在这里我迷失了。这是我的代码。

{foreach from=$array_groups[$group_id] item=categ name=categs}

                                  <input type='checkbox' name='{$categ.category_id}' value='{$categ.category_id}'  id='{$categ.category_id}' ><label for='{$categ.category_id}' >{$categ.category_name}</label><br>

        {if ($smarty.foreach.categs.index+1)%$aSettings.videos_cols==0}</td><td valign='top' align='left'>{/if}               

{/foreach}  

它在5个类别之后添加了这段HTML代码</td><td valign='top' align='left'>,但我想为类别添加自定义数字,而不是为视频设置的数字。我不知道如何更改此代码%$aSettings.videos_cols==0

1 个答案:

答案 0 :(得分:0)

更改,

    {if ($smarty.foreach.categs.index+1)%$aSettings.videos_cols==0}</td><td valign='top' align='left'>{/if}               

    {if ($smarty.foreach.categs.index+1)%5==0}</td><td valign='top' align='left'>{/if}               

只需更改数字5。

相关问题