typescript object类型(Typecho 程序如何调用循环页面、分类、标签代码方法)
导读:在我们日常使用Typecho程序制作主题或者修改主题模板的时候,会用到循环页面或者分类、标签代码的调用,这里我们可以将常用的这三个调用代码记录下来。...
在我们日常使用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; ?> <!--结束显示标签-->创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!