1.最简单的方法,不是循环出来的
<ul class="clearfix">
<li class="active"><a href="{:url('index/index')}">HOME</a></li>
<li><a href="{:url('single/company')}">COMPANY</a></li>
<li><a href="{:url('product/list')}">PRODUCTS</a>
<ul class="suMen">
<li><a href="{:url('product/list')}">Plastic Bottle</a></li>
<li><a href="{:url('product/list')}">Glass Bottle</a></li>
<li><a href="{:url('product/list')}">Vacuum Thermos Pot</a></li>
<li><a href="{:url('product/list')}">Stainless Steel Bottle</a></li>
</ul>
</li>
<li><a href="{:url('news/arrivals')}">NEW ARRIVALS</a></li>
<li><a href="{:url('single/cooperation')}">COOPERATION</a></li>
<li><a href="javascript:void(0)">CONTACTS</a>
<ul class="suMen">
<li><a href="{:url('single/contact')}">Contact us</a></li>
<li><a href="{:url('single/contact')}"></a></li>
<li><a href="{:url('single/contact')}">FAQs</a></li>
</ul>
</li>
</ul>
2.循环出来的
2.1
PHP判断数组下标有没有存在的方法
array_key_exists("$key", $array)
//$key 下标 $array 数组
<ul class="clearfix">
{foreach name="Navigation" item="value"}
<?php if(array_key_exists("child", $value)){?>
<li>
<a href="{$value.link}">{$value.name}</a>
<ul class="suMen">
{foreach name="value.child" item="val"}
<li><a href="{$val.link}">{$val.name}</a></li>
{/foreach}
</ul>
</li>
<?php }else{?>
<li><a href="{$value.link}">{$value.name}</a></li>
<?php }?>
{/foreach}
</ul>
2.2
<foreach name="Navigation" item="value">
<if condition="count($value['child']) neq 0">
<li>
<a href="{$value.link}">{$value.name}</a>
<div class="sub_menu">
<ul class="clearfix">
<foreach name="value.child" item="val">
<li class="hoverli">
<a href="{$val.link}"><i class="fa fa-angle-right" aria-hidden="true"></i> {$val.name}</a>
<ul class="navul">
<foreach name="val.child" item="va">
<li><a href="{$va.link}"><i class="fa fa-angle-right" aria-hidden="true"></i> {$va.name}</a></li>
</foreach>
</ul>
</li>
</foreach>
</ul>
</div>
</li>
<else/>
<li><a href="{$value.link}">{$value.name}</a></li>
</if>
</foreach>
2.3
{foreach name="Navigation" item="vo"}
{if condition="$vo.pid eq 0"}
<li><a href="{$vo.link}">{$vo.name}</a>
<ul class="suMen">
{foreach name="Navigation" item="vos"}
{if condition="$vos.pid eq $vo.id"}
<li><a href="{$vos.link}">{$vos.name}</a></li>
{/if}
{/foreach}
</ul>
</li>
{/if}
{/foreach}