在我们日常使用Typecho程序制作主题或者修改主题模板的时候,会用到循环页面或者分类、标签代码的调用,这里我们可以将常用的这三个调用代码记录下来。

<!--循环显示页面-->
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while($pages->next()): ?>

<?php $pages->title(); ?>


<?php endwhile; ?>
<!--结束显示页面-->

<!--循环所有分类-->
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while ($category->next()): ?>

<?php $category->name(); ?>


<?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()): ?>

<?php $tags->name(); ?>


<?php endwhile; ?>
<!--结束显示标签-->


扫描二维码,在手机上阅读!