在開發的過程中經常會用到if判斷條件,那么如何在dedecms的{dede:list}標簽中使用if進行條件判斷呢?我們可以參考以下代碼:
{dede:list pagesize='10'}
<ul>
<li><a href="[field:arcurl/]" target="_blank">[field:array runphp='yes']@me = (empty(@me['litpic']) ? "" : "<img src='{@me['litpic']}' width='217' height='167' border='0' />"); [/field:array]</a></li>
<li class="ht"><a href="[field:arcurl/]" target="_blank">[field:title/]</a></li>
<li><a href="[field:arcurl/]" target="_blank"><img src="/img/bw.jpg" width="154" height="32" border="0" /></a></li>
</ul>
{/dede:list}
另一種形式的if判斷應用示例代碼:
{dede:list pagesize='33'}
<li class="hang">
<a href="[field:arcurl/]" target="_blank">[field:title /]</a>
<span class="sj">
[field:pubdate function="MyDate('Y-m-d',@me)"/]
</span>
</li>
[field:global runphp='yes' name=autoindex]
$c = '<li class="xian"></li>';
if((@me % 6) == 0) @me = $c;
else @me = '';
[/field:global]
{/dede:list}
{dede:list pagesize='10'}
<ul>
<li><a href="[field:arcurl/]" target="_blank">[field:array runphp='yes']@me = (empty(@me['litpic']) ? "" : "<img src='{@me['litpic']}' width='217' height='167' border='0' />"); [/field:array]</a></li>
<li class="ht"><a href="[field:arcurl/]" target="_blank">[field:title/]</a></li>
<li><a href="[field:arcurl/]" target="_blank"><img src="/img/bw.jpg" width="154" height="32" border="0" /></a></li>
</ul>
{/dede:list}
另一種形式的if判斷應用示例代碼:
{dede:list pagesize='33'}
<li class="hang">
<a href="[field:arcurl/]" target="_blank">[field:title /]</a>
<span class="sj">
[field:pubdate function="MyDate('Y-m-d',@me)"/]
</span>
</li>
[field:global runphp='yes' name=autoindex]
$c = '<li class="xian"></li>';
if((@me % 6) == 0) @me = $c;
else @me = '';
[/field:global]
{/dede:list}