wpgcms---循环导航
使用wpgcms的时候,在后台设置了导航菜单,那么在前端是如何循环呢?
第一种:简便方法
{% set array = [ {name:'移动APP',icon:'icon-yidongAPP',code:'app'}, {name:'微信开发',icon:'icon-weixinkaifa',code:'weixin'}, {name:'网站开发',icon:'icon-wangzhankaifa',code:'kaifa'}, {name:'医疗信息化',icon:'icon-yiliaoxinxihua',code:'yiliao'}, {name:'学习系统',icon:'icon-zaixianxuexixitong',code:'xuexi'}, {name:'电商系统',icon:'icon-BBCdianshangxitong',code:'dianshang'}, {name:'智慧校园',icon:'icon-zhihuixiaoyuan',code:'zhihuixiaoyuan'}, {name:'党建平台',icon:'icon-zhihuidangjianpingtai',code:'dangjian'}, {name:'互联网应用',icon:'icon-gongyewanghulianwangyingyong',code:'hulianwang'}, ] %} {% for item in array %} <li class="com {% if contentInfo.code == item.code %}active{% endif %}"> <a href="/solution/{{ item.code }}.html"> <span class="icon"><i class="icon iconfont {{ item.icon }}"></i></span> <span class="text">{{ item.name }}</span> </a> </li> {% endfor %}
第二种方法:调用navigation的get方法获取导航
{% set mainNavs = wpg.navigation.get('main') %} {% set sidebar = mainNavs[1] %} {% for item in sidebar.items %} <li class="com {% if item.active %}active{% endif %}"> <a href="{{ item.url }}"> <span class="icon"><i class="icon iconfont {{ item.icon }}"></i></span> <span class="text">{{ item.name }}</span> </a> </li> {% endfor %}