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

<!--循环显示页面-->
<?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="https://www.yuucn.com/<?php $pages->permalink(); ?>" 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="https://www.yuucn.com/<?php $category->permalink(); ?>" 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="https://www.yuucn.com/<?php $tags->permalink(); ?>" title="<?php $tags->name(); ?>">
<span><?php $tags->name(); ?></span>
</a>
</span>
<?php endwhile; ?>
<!--结束显示标签-->
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。