第一种
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php if ($category->have()): ?>
<?php while ($category->next()): ?>
<?php if ($category->levels == 0): ?>
<?php $children = $category->getAllChildren($category->mid); ?>
<?php if (empty($children)) :?>
<li><a href="<?php $category->permalink() ?>"><?php $category->name() ?></a></li>
<?php else : ?>
<li><a href="<?php $category->permalink() ?>"><?php $category->name() ?></a>
<ul>
<?php foreach ($children as $child ): ?>
<?php $child = $category->getCategory($child) ?>
<li><a href="<?php echo $child['permalink']; ?>"> <?php echo $child['name']; ?></a></li>
<?php endforeach ?>
</ul>
</li>
<?php endif ?>
<?php endif ?><?php endwhile; ?>
<?php endif ?>
第二种
<?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
<?php while($categorys->next()): ?>
<?php if ($categorys->levels === 0): ?>
<?php $children = $categorys->getAllChildren($categorys->mid); ?>
<?php if (empty($children)) : ?>
<li> <?php if($this->is('category', $categorys->slug)): ?> <?php endif; ?>
<a href="<?php $categorys->permalink(); ?>" title="<?php $categorys->name(); ?>"><?php $categorys->name(); ?></a>
</li>
<?php else : ?>
<li><a href="<?php $categorys->permalink(); ?>"><?php $categorys->name(); ?> </a>
<ul>
<?php foreach ($children as $mid): ?>
<?php $child = $categorys->getCategory($mid); ?>
<li <?php if($this->is('category', $mid)): ?> class="current-menu-item"<?php endif; ?> >
<a href="<?php echo $child['permalink'] ?>" title="<?php echo $child['name']; ?>"><?php echo $child['name']; ?> </a>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endif; ?>
<?php endif; ?><?php endwhile; ?>