keyof 发表于 2010-11-23 12:21:02

分页问题求救

本帖最后由 keyof 于 2010-11-24 08:26 编辑

我用STBLOG带的分页类,也就是这个分页类:http://mis-algoritmos.com/digg-style-pagination-class
控制器是这样写的:

$query=array();
$page = $this->input->get('p',TRUE);
$page = (!empty($page) && is_numeric($page)) ? intval($page) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;

if($offset < 0)
{
   redirect('welcome');
}

$posts = $this->posts->get_posts($limit, $offset);
$posts_count = $this->posts->get_posts(10000, 0)->num_rows();

if($posts)
{
   $pagination = '';
   
   if($posts_count > $limit)
   {
    $this->dpagination->currentPage($page);
    $this->dpagination->items($posts_count);
    $this->dpagination->limit($limit);
    $this->dpagination->adjacents(5);
    $this->dpagination->target(site_url('welcome?'.implode('&',$query)));
    $this->dpagination->parameterName('p');
    $this->dpagination->nextLabel('pre');
    $this->dpagination->;PrevLabel('nex');
   
    $pagination = $this->dpagination->getOutput();
   }
}
$this->_data['pagination'] = $pagination;
$this->_data['parentPage'] = 'welcome';
$this->_data['currentPage'] = 'welcome';
$this->_data['posts'] = $posts;

$this->load->view('welcome_message',$this->_data);

模型是:

const TBL_POSTS = 'cioa_infopass';
    public function __construct()
    {
parent::Model();
   }

public function get_posts($limit = NULL,$offset = NULL)
{
//limit
if($limit && is_numeric($limit))
{
   $this->db->limit(intval($limit));
}

//offset
if($offset && is_numeric($offset))
{
   $this->db->offset(intval($offset));
}

return $this->db->get(self::TBL_POSTS);
}


视图是:

<table class="typecho-list-table">
                  <colgroup>
                        <col width="25"/>                        
                        <col width="235"/>                        
                        <col width="200"/>
                        <col width="165"/>
                        <col width="165"/>
                  </colgroup>
                  <thead>
                        <tr>
                            <th class="typecho-radius-topleft"> </th>                           
                            <th>标题</th>
                            <th> </th>                           
                            <th>作者</th>                           
                            <th>分类</th>
                            <th class="typecho-radius-topright">发布日期</th>
                        </tr>
                  </thead>
                  <tbody>
      <?php if($posts->num_rows() > 0):?>
      <?php foreach($posts->result() as $post):?>
                        <tr<?php echo ($post->ID % 2==0)?'':' class="even"'; ?> id="<?php echo 'post-'.$post->ID; ?>">
                            <td><input type="checkbox" value="<?php echo $post->ID; ?>" name="pid[]"/></td>
                           
                            <td><?php echo anchor(site_url('admin/posts/write/'.$post->ID),$post->Title);?></td>
                            <td>
                            <?php if ('1' == $post->IfDone): ?>
                            <a class="right hidden-by-mouse" href="<?php echo site_url('posts/'.$post->InfoType); ?>"><img src="<?php echo base_url();?>application/views/images/view.gif" title="<?php echo '浏览'. $post->Title; ?>" width="16" height="16" alt="view" /></a>
                            <?php endif; ?>
                            </td>
                            <td><?php echo anchor("admin/posts/manage/?author=".$post->UserID,$post->Title); ?></td>
                            <td>
                              <?php echo anchor("admin/posts/manage/?infotype=".$post->InfoType,$post->InfoType); ?>
                     </td>                           
                        </tr>
                        <?php endforeach; ?>
                        <?php else: ?>
                        <tr class="even">
                         <td colspan="7"><h6 class="typecho-list-table-title">没有任务文章</h6></td>
                        </tr>
                        <?php endif; ?>
                  </tbody>
                </table>
                <?php echo isset($pagination)?$pagination:''; ?>

看似都正常就是点所有页都没有反应

Hex 发表于 2010-11-23 13:45:14

请 Saturn 来解答这个问题。呵呵

keyof 发表于 2010-11-23 14:19:02

请 Saturn 来解答这个问题。呵呵
Hex 发表于 2010-11-23 13:45 http://codeigniter.org.cn/forums/images/common/back.gif


    :dizzy: :dizzy: 不带你这么玩的,满心欢喜看到您回复了,Saturn,你在哪了?

keyof 发表于 2010-11-24 08:27:28

自己解决了,还是得靠自己,哎
页: [1]
查看完整版本: 分页问题求救