typecho 热门文章调用方法 (阅读最多的调用方法)

//热门文章
class Widget_Contents_Hot extends Widget_Abstract_Contents
{
public function execute()
{
    $this->parameter->setDefault(array('pageSize' => 10));
    $select = $this->select();
    $select->cleanAttribute('fields');
    $this->db->fetchAll(
        $select->from('table.contents')
            ->where("table.contents.password IS NULL OR table.contents.password = ''")
            ->where('table.contents.status = ?', 'publish')
            ->where('table.contents.created <= ?', time())
            ->where('table.contents.type = ?', 'post')
            ->limit($this->parameter->pageSize)
            ->order('table.contents.views', Typecho_Db::SORT_DESC),
        array($this, 'push')
    );
}
}

调用方法

  <?php $this->widget('Widget_Contents_Hot@Index', 'pageSize=4')->to($item); ?>
                        <?php while ($item->next()) : ?>
   <?php $item->permalink(); ?>//调用方法
   <?php $item->title(); ?>//调用方法   
  //其他方法自己参考更改就行了

  <?php endwhile; ?>

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