极致CMS导航栏调用方法,导航栏标签
导航栏
判断是否首页,输出高亮代码
<li><a class="a1 {if(!isset($type))}color{/if}" href="/">首页</a></li>
{foreach $classtypedata as $v}
判断输出可显示的栏目
{if($v['isshow']==1)}
输出一级栏目
{if($v['pid']==0)}
<li>
判断是否当前栏目,输出高亮代码
<a class="a1 {if(isset($type) && in_array($type['id'],$v['children']['ids']))}color{/if}" href="{$v['url']}">{$v['classname']}</a>
判断是否有下级,输出下级分类
{if($v['haschild'])}
<ul>
{foreach $v['children']['list'] as $vv}
{if($vv['isshow']==1)}
<li><a href="{$vv['url']}">{$vv['classname']}</a></li>
{/if}
{/foreach}
</ul>
{/if}
</li>
{/if}
{/if}
{/foreach}输出二级三级
{foreach $classtypedata as $v}
{foreach $v['children']['list'] as $vv}
{foreach $classtypedata[$vv['id']]['children']['list'] as $vvv}
//三级以上输出,借助 $classtypedata来获取下级数据
{/foreach}
{/foreach}
{/foreach}使用loop输出栏目
{loop table="classtype" pid="0" isshow="1" as="v"}
<li>
判断是否当前栏目,输出高亮代码
<a class="a1 {if(isset($type) && in_array($type['id'],$classtypedata[$v['id']]['children']['ids']))}color{/if}" href="{$v['url']}">{$v['classname']}</a>
判断是否有下级,输出下级分类
{if($classtypedata[$v['id']]['haschild'])}
<ul>
{foreach $classtypedata[$v['id']]['children']['list'] as $vv}
<li><a href="{$vv['url']}">{$vv['classname']}</a></li>
{/foreach}
</ul>
{/if}
</li>
{/loop}判断是否首页
{if($ishome)} // 1.9.3+新增
首页
{/if}
{if(!isset($type))}
首页
{/if}获取当前栏目最顶级栏目
{php $topclass = array_shift($positions_data) /}可以直接使用 {$topclass[$str]} 输出对应的栏目内容 如:栏目名 {$topclass['classname']}
本文属原创,转载请注明原文:https://www.zhimatong.com/jiaocheng/885.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
内容有用



交流群
购物车