|
发表于 2013-10-20 21:20:04
|
显示全部楼层
给你提供一个思路,看得懂看不懂看你自己了:
PHP复制代码
function shwo_all_articles ($category_id,$category_name,$page) //显示此板块下所有文章
{
$i = 0;
if ($this->_get_all_article ($category_id)) {
foreach ($this->_get_all_article ($category_id) as $row) {
$i++;
if ($i <= ($page-1)*10) { //根据传递过来的$article_id参数,确定循环输出起点
continue;
} elseif ($i > $page*10) {
break;
}
$data['title'] = $row->title;
$data['date'] = $row->date;
$data['article_id'] = $row->a_id;
......
}
}
//分页
$this->load->library('pagination');
$config['base_url'] = base_url ().'admin/category/'.$category_id.'/';
$config['total_rows'] = $this->admin_right->get_article_number($category_id);
$config['per_page'] = 10;
$config['use_page_numbers'] = TRUE;
$config['full_tag_open'] = '<div id="pagenav">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = '第一页';
$config['last_link'] = '最后一页';
$config['uri_segment'] = 4;
$config['num_links'] = 1;
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$this->pagination->initialize($config);
......
}
复制代码 |
|