{foreach name=outer item=contact from=$records}
<tr>
<td width="100%" class="Gold_type_14_b" height="30">
{foreach key=key item=item from=$contact }{if $key=="id"}<div style="width:470px;align:center;float:left">
<a href="xwdetail.php?id={$item}">{/if}{if $key=="content"}{$item|smartTruncate:30:"..."}</a></div>
{/if}
{/foreach}</td>
</tr>
{/foreach}
问题是:
数据库字段有url,content,type
作这样的判断{if $key==type}{if $type==1} 则输出 content{/if}{/if}
else 输出 url
现在用了两个foreach 循环很麻烦
红色部分有问题了,不知道怎么弄
<tr>
<td width="100%" class="Gold_type_14_b" height="30">
{foreach key=key item=item from=$contact }{if $key=="id"}<div style="width:470px;align:center;float:left">
<a href="xwdetail.php?id={$item}">{/if}{if $key=="content"}{$item|smartTruncate:30:"..."}</a></div>
{/if}
{/foreach}</td>
</tr>
{/foreach}
问题是:
数据库字段有url,content,type
作这样的判断{if $key==type}{if $type==1} 则输出 content{/if}{/if}
else 输出 url
现在用了两个foreach 循环很麻烦
红色部分有问题了,不知道怎么弄
<a href="xwdetail.php?id={$item}">{/if}{if $key=="content"}{$item|smartTruncate:30:"..."}</a></div>
{/if}
就是上面这一块
如果type=1 就输出<a href="超链接指向url">主体内容</a>如果type=0 就输出<a href="超链接指向content">主体内容</a>
就是这样的逻辑啊
内容
{else}
内容
{/if}
要输出type必须得这样写啊{if $key=="type"}$item{/if}