typecho输出导航(二级)和独立页面代码

typecho输出导航(二级)和独立页面代码

留个痕迹,方便往后查询……

如题

一级分类导航代码:

<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while($category->next()): ?>
<a href="<?php $category->permalink(); ?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>

独立页面:

<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while($pages->next()): ?>
<a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>

二级分类导航代码:

<?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 class="header__nav-item">    <a href="<?php $categorys->permalink(); ?>" class="header__nav-link"><?php $categorys->name(); ?></a></li>
<?php } else { ?>
<li class="header__nav-item"><a class="dropdown-toggle header__nav-link" href="#" role="button" id="dropdownMenuProjects" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php $categorys->name(); ?></a>
<ul class="dropdown-menu header__dropdown-menu" aria-labelledby="dropdownMenuProjects">
<li><a href="<?php $categorys->permalink(); ?>"><?php $categorys->name(); ?></a></li>
<?php foreach ($children as $mid) { ?>
<?php $child = $categorys->getCategory($mid); ?>
<li><a href="<?php echo $child['permalink'] ?>"><?php echo $child['name']; ?></a></li>
<?php } ?>
</ul></li>
<?php } ?>
<?php endif; ?>
<?php endwhile; ?>

二级分类导航,就稍微复杂一点…… 里面的格式具体根据自己的主题修改调整把

文章由官网发布,如若转载,请注明出处:https://www.veimoz.com/823
0 评论
3.6k

发表评论

!