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

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

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

如题

一级分类导航代码:

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

独立页面:

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

二级分类导航代码:

  1. <?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
  2. <?php while($categorys->next()): ?>
  3. <?php if ($categorys->levels === 0): ?>
  4. <?php $children = $categorys->getAllChildren($categorys->mid); ?>
  5. <?php if (empty($children)) { ?>
  6. <li class="header__nav-item"> <a href="<?php $categorys->permalink(); ?>" class="header__nav-link"><?php $categorys->name(); ?></a></li>
  7. <?php } else { ?>
  8. <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>
  9. <ul class="dropdown-menu header__dropdown-menu" aria-labelledby="dropdownMenuProjects">
  10. <li><a href="<?php $categorys->permalink(); ?>"><?php $categorys->name(); ?></a></li>
  11. <?php foreach ($children as $mid) { ?>
  12. <?php $child = $categorys->getCategory($mid); ?>
  13. <li><a href="<?php echo $child['permalink'] ?>"><?php echo $child['name']; ?></a></li>
  14. <?php } ?>
  15. </ul></li>
  16. <?php } ?>
  17. <?php endif; ?>
  18. <?php endwhile; ?>

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

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

发表评论

!