typecho教程:循环页面、分类、标签
循环页面、分类、标签
03-18
<!--循环显示页面--> <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?> <?php while($pages->next()): ?> <span class="nav-item<?php if($this->is('page', $pages->slug)): ?> nav-item-current<?php endif; ?>"> <a href="<?php%20$pages->permalink();%20?>" title="<?php $pages->title(); ?>"> <span><?php $pages->title(); ?></span> </a> </span> <?php endwhile; ?> <!--结束显示页面--> <!--循环所有分类--> <?php $this->widget('Widget_Metas_Category_List')->to($category); ?> <?php while ($category->next()): ?> <span class="nav-item<?php if($this->is('category', $category->slug)): ?> nav-item-current<?php endif; ?>"> <a href="<?php%20$category->permalink();%20?>" title="<?php $category->name(); ?>"> <span><?php $category->name(); ?></span> </a> </span> <?php endwhile; ?> <!--结束显示分类--> <!--循环显示标签 其中limit的5为显示数量--> <?php $this->widget('Widget_Metas_Tag_Cloud', array('sort' => 'count', 'ignoreZeroCount' => true, 'desc' => true, 'limit' => 5))->to($tags); ?> <?php while($tags->next()): ?> <span class="nav-item<?php if($this->is('tag', $tags->slug)): ?> nav-item-current<?php endif; ?>"> <a href="<?php%20$tags->permalink();%20?>" title="<?php $tags->name(); ?>"> <span><?php $tags->name(); ?></span> </a> </span> <?php endwhile; ?> <!--结束显示标签-->