Dedehtml.com

织梦导航栏目顶级和二级判断二级输出不同url

摘要:判断是否有子栏目,有就输出 javascript:; ,没有子栏目就直接输出一级栏目的链接

需求

有二级栏目时一级栏目的Url输出 javascript:; 只有一级栏目就输出链接

解答

判断是否有子栏目,有就输出 javascript:; ,没有子栏目就直接输出一级栏目的链接

{dede:field name=typeid runphp=yes}global $dsql;$row = $dsql->GetOne("select * from `#@__arctype` where reid='@me' and ishidden<>1 order by sortrank asc limit 0,1");if(is_array($row)) @me = 'javascript:;'; else @me = GetOneTypeUrlA($dsql->GetOne("select * from `#@__arctype` where id='@me' and ishidden<>1"));{/dede:field}

示范

{dede:channelartlist row=7 typeid=top currentstyle=current}
<li>
	<a href="{dede:field name=typeid runphp=yes}global $dsql;$row = $dsql->GetOne("select * from `#@__arctype` where reid='@me' and ishidden<>1 order by sortrank asc limit 0,1");if(is_array($row)) @me = 'javascript:;'; else @me = GetOneTypeUrlA($dsql->GetOne("select * from `#@__arctype` where id='@me' and ishidden<>1"));{/dede:field}"><span>{dede:field.typename/}</span>{dede:channel type='son' row=1 noself='yes'}<i class="touch-arrow-down"></i>{/dede:channel}</a>
	{dede:channel type='son' row=1 noself='yes'}
	<ul>
	{/dede:channel}
		{dede:channel type='son' noself='yes'}
		<li><a href="[field:typelink/]"><span>[field:typename/]</span></a></li>
		{/dede:channel}
	{dede:channel type='son' row=1 noself='yes'}
	</ul>
	{/dede:channel}
</li>
{/dede:channelartlist}

结果

版权声明:本文为博主原创文章,未经博主允许不得转载。https://www.dedehtml.com/notes/dede-catalog-son.html
(5)
打赏 微信扫一扫 微信 支付宝 QQ 扫码打赏