织梦判断是否有子栏目,有就输出 javascript:; ,没有子栏目就直接输出超链接地址

养成好习惯是储存健康,放纵不良是透支生命。我们一生之中,要牢记和要忘记的东西一样多。

织梦判断是否有子栏目,有就输出 javascript:; ,没有子栏目就直接输出超链接地址代码写法,今天我们在做一个自适应结构的网站的时候会经常碰到实现这样的效果,如图所示。

实现要求:

一般用作手机站,点击弹开子菜单,但当某栏目没有子栏目时则需要输出链接地址。

实现效果:

代码写法:

{dede:channelartlist row='8' typeid='top'}
      <li class="main_item "> <a rel="nofollow noopener noreferrer" 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 name='typename'/}</span></a>
        <ul {dede:field name=typeid runphp="yes"}
global $dsql;
$sql = "SELECT id From `#@_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
$row = $dsql->GetOne($sql);
          @me=is_array($row)" />
<li class="main_item "> <a rel="nofollow noopener noreferrer" href="javascript:;"><span>关于我们</span></a>
        <ul class="drop_list">
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/gongsigaikuang/" title="公司概况">公司概况</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/changfangshebei/" title="厂房设备">厂房设备</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/pinpairongyu/" title="品牌荣誉">品牌荣誉</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/gongsifengcai/" title="公司风采">公司风采</a></li>
           
        </ul>
      </li><li class="main_item "> <a rel="nofollow noopener noreferrer" href="/xinpintuijian/"><span>新品推荐</span></a>
        <ul style="display:none">
           
        </ul>
      </li><li class="main_item "> <a rel="nofollow noopener noreferrer" href="javascript:;"><span>全部产品</span></a>
        <ul class="drop_list">
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/quanbuchanpin/Dleimiehuoqi/" title="D类灭火器">D类灭火器</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/quanbuchanpin/chezaimiehuoqi/" title="车载灭火器">车载灭火器</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/quanbuchanpin/ganfenmiehuoji/" title="干粉灭火剂">干粉灭火剂</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/quanbuchanpin/chukouhanguoganfen/" title="出口韩国干粉">出口韩国干粉</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/quanbuchanpin/paomomiehuoji/" title="泡沫灭火剂">泡沫灭火剂</a></li>
           
        </ul>
      </li><li class="main_item "> <a rel="nofollow noopener noreferrer" href="/hezuohuoban/"><span>合作伙伴</span></a>
        <ul style="display:none">
           
        </ul>
      </li><li class="main_item "> <a rel="nofollow noopener noreferrer" href="javascript:;"><span>新闻中心</span></a>
        <ul class="drop_list">
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/xinwenzhongxin/xingyexinwen/" title="行业新闻">行业新闻</a></li>
           
           <li><a class="novlink" rel="nofollow noopener noreferrer" href="/xinwenzhongxin/gongsixinwen/" title="公司新闻">公司新闻</a></li>
           
        </ul>
      </li><li class="main_item "> <a rel="nofollow noopener noreferrer" href="/lianxiwomen/"><span>联系我们</span></a>
        <ul style="display:none">
           
        </ul>
      </li>

本文织梦判断是否有子栏目,有就输出 javascript:; ,没有子栏目就直接输出超链接地址到此结束。心常用则活,不用则窒。常用则细,不用则粗。小编再次感谢大家对我们的支持!

标签: 超链接