typecho导航含二级导航输出

效果:

可以在导航出现二级导航

方法:
第一种,直接调用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; ?>
熊猫博客打赏
*打赏支持:支付宝/微信,请熊猫喝杯卡布奇诺吧

除特殊说明,原创内容采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可

标签: Typecho技巧

发表评论: