最新文章

<?php
  $this->widget('Widget_Contents_Post_Recent','pageSize=6')->to($recent);
  if($recent->have()):
  while($recent->next()):
   ?>
  <li><a href="<?php $recent->permalink();?>"><?php $recent->title();?></a></li>
<?php endwhile; endif;?>

最热文章

<?php getHotComments('8');?>
// 最热文章调用
function getHotComments($limit = 10){
    $db = Typecho_Db::get();
    $result = $db->fetchAll($db->select()->from('table.contents')
        ->where('status = ?','publish')
        ->where('type = ?', 'post')
        ->where('created <= unix_timestamp(now())', 'post')
        ->limit($limit)
        ->order('commentsNum', Typecho_Db::SORT_DESC)
    );
    if($result){
        foreach($result as $val){
            $val = Typecho_Widget::widget('Widget_Abstract_Contents')->push($val);
            $post_title = htmlspecialchars($val['title']);
            $permalink = $val['permalink'];
            echo '<li><i></i><a href="'.$permalink.'" title="'.$post_title.'" >'.$post_title.'</a></li>';
        }
    }
}