オフセットの代わりにページ番号を使用するように、ページ分類クラス(/system/libraries/Pagination.php)で次の変更を行います。
OLD(ライン146-153):
if ($CI->uri->segment($this->uri_segment) != 0)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
NEW:
if文のデフォルトがあることを確認するために「他」オプションを追加します。ページ= 1
if ($CI->uri->segment($this->uri_segment) != 0)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
else
{
$this->cur_page = 1;
}
OLD(ライン175):
$this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
NEW:
現在のページは、コントローラ/ URIに従うように、単純にこの行をコメントアウトします。
//$this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
OLD(ライン206):
$i = $uri_page_number - $this->per_page;
NEW:
前のページが常に現在のページが1減算されるべきである
$i = $uri_page_number - 1;
OLD (ライン230):
if ($this->cur_page == $loop)
NEW:改ページが欠落し
URIは、ページ1考慮すべきです。
if ($this->cur_page == $loop || ($this->cur_page == 1 && $this->cur_page == $loop))
OLD(ライン238から247):
if ($n == '' && $this->first_url != '')
{
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close;
}
else
{
$n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
}
NEW:
ページのURLは、ページ番号ではなくオフセットを使用する必要があります。
if ($n == '' && $this->first_url != '')
{
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$loop.'">'.$loop.'</a>'.$this->num_tag_close;
}
else
{
$n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$loop.'">'.$loop.'</a>'.$this->num_tag_close;
}
OLD(ライン256):
$output .= $this->next_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close;
NEW:
次のページには、常に現在のページの合計と1
$output .= $this->next_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page + 1).$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close;
する必要があります旧式(ライン262):
$i = (($num_pages * $this->per_page) - $this->per_page);
NEW:
最後のページは、ページの合計数でなければなりません。
$i = $num_pages;
すべての古い行を新しい行に置き換えます。変更する前に必ずファイルのバックアップを取ってください。
希望はこのことができます:)
編集:私は$per_page * ($start_from-1)
で新しい変数$開始を追加した。ここ
function test($start_from = 0)
{
$this->load->library('pagination');
$data = array();
$per_page = 3;
$total = $this->activity_model->count_by();
$config['base_url'] = base_url() . 'test';
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['uri_segment'] = 2;
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$start = $per_page * ($start_from-1);
$data['follow'] = $this->activity_model->get($per_page, $start);
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('front_end/test' ,$data);
}
:のようなあなたのコントローラ機能テストを更新する必要が
。今、この$ startを引数としてモデルに渡します。ページごとのアイテムが10
であり、あなたが2番目のページ10
を与える$start = 10 *(2-1)
上にある場合は、このDOはしてページあたりの項目数を掛けている何
(現在のページ番号は-1).Thisを意味します。だからあなたの結果は、10,20からスタートしますので、1人の
希望はこのことができます:)
で私をつぶやくクエリに対してこのことができます
希望... をこれは、CodeIgniterの2.0.3のために行くのだろうか?とにかくありがとうございました ! – Viktors
行番号に若干の変更があります。どんな方法でも試してみてください。私のものは少し古いバージョンです。それが動作する場合私にお知らせください:) – Sabari
これはあなたのために働くか? – Sabari