效果:
可以在导航出现二级导航
方法:
第一种,直接调用typecho函数来实现
<?php $this->widget('Widget_Metas_Category_List')->listCategories('wrapClass=widget-list'); ?>
<style type="text/css">
.category-parent .category-child {display: none;}
.category-parent:hover .category-child {display: block;}
</style>
具体参数:请查看var/Widget/Metas/Category/List.php文件中的listCategories函数
'wrapTag' => 'ul',
'wrapClass' => '',
'itemTag' => 'li',
'itemClass' => '',
'showCount' => false,
'showFeed' => false,
'countTemplate' => '(%d)',
'feedTemplate' => '<a href="%s">RSS</a>'
第二种:
<?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)): ?> class="active"<?php endif; ?>>
<a href="<?php $categorys->permalink(); ?>" title="<?php $categorys->name(); ?>"><?php $categorys->name(); ?></a>
</li>
<?php } else { ?>
<li >
<a data-toggle="dropdown" href="#" data-target="#"><?php $categorys->name(); ?></a>
<ul class="png">
<?php foreach ($children as $mid) { ?>
<?php $child = $categorys->getCategory($mid); ?>
<li <?php if($this->is('category', $mid)): ?> class="active"<?php endif; ?>>
<a href="<?php echo $child['permalink'] ?>" title="<?php echo $child['name']; ?>"><?php echo $child['name']; ?></a>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>
<?php endif; ?>
<?php endwhile; ?>