在制造两栏typecho博客主题时,假如想在网站的侧边栏挪用肯定数量的博客最新文章列表怎么办?要领很简单,运用Widget_Contents_Post_Recent这个widget即可挪用,经由过程pageSize参数即可限定挪用数量。
代码一
123 | <?php $this->widget('Widget_Contents_Post_Recent','pageSize=10')->parse('<li><a href="{permalink}"><span>{year}/{month}/{day}</span>{title}</a></li>'); ?> |
参数申明:
{year} – 文章宣布时候年份
{month} – 文章宣布时候月份
{day} – 文章宣布时候天
{title} – 文章标题
代码二
1234567 | <?php $this->widget('Widget_Contents_Post_Recent','pageSize=10')->to($recent);if($recent->have()):while($recent->next()):?><li><a href="<?php $recent->permalink();?>"><?php $recent->title();?></a></li><?php endwhile; endif;?> |
代码三
1234567 | <?php $recent = $this->widget('Widget_Contents_Post_Recent','pageSize=10');if($recent->have()):while($recent->next()):?> <li><a href="<?php $recent->permalink();?>"><?php $recent->title();?></a></li><?php endwhile; endif;?> |
提醒:把代码pageSize=10中的10为要挪用的文章数量。
函数位于var/Widget/Contents/Post/Recent.php
文章由 博客吧 整顿宣布

评论列表