1、有短标题显示短标题,没有短标题显示标题(这个是唯一一个可以多个字段判断的语句,大家可以拓展使用)
[field:array runphp='yes'] if (@me['shorttitle']=='') @me=@me['title'];else @me=@me['shorttitle'];[/field:array]
2、隔行换色常用语句,通过autoindex判断,然后输出class进行分段换行:
[field:global name='autoindex'runphp='yes']if(@me%2==0){@me='class="rr"';}else{@me='';}[/field:global]
3、顶部导航输出经典判断语句,这个主要是子栏目的判断,有子栏目就输出对应的ul,没有就不输出,下面贴出整段代码,自己按照样式进行修改:
{dede:channelartlist typeid='top' currentstyle='active'}
<li class="navitem"><a href="{dede:field name='typeurl'/}" class="{dede:field.currentstyle/}" target="_self"><span data-title="{dede:field name='typename'/}">{dede:field name='typename'/}</span>
{dede:field name=typeid runphp="yes"}
global $dsql;
$sql = "SELECT id From `wmd_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
$row = $dsql->GetOne($sql);
@me=is_array($row)?"<i class='fa fa-angle-down'></i></a><ul class='subnav'>":"</a>";
{/dede:field}
{dede:channel}
<li><a href="[field:typeurl/]">[field:typename/]</a></li>
{/dede:channel}
{dede:field name=typeid runphp="yes"}
global $dsql;
$sql = "SELECT id From `wmd_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
$row = $dsql->GetOne($sql);
@me=is_array($row)?"</ul>":"";
{/dede:field}
</li>
{/dede:channelartlist}
4、判断匹配是否包含http的网址,没有就加上根目录地址,有就直接输出:
$row = $dsql->GetOne("SELECT downloads FROM wmd_soft WHERE aid= $id");
if(preg_match('/^http(s)?:\\/\\/.+/',$row['downloads']))
{$url = $row['downloads']; }else
{$url = $cfg_basehost.$row['downloads'];}
先整理这么多,等想起来其他的再为大家整理!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!