0
私のURLに問題があります。私のページネーションはとてもうまくいくが、それほど美しく見えない。 は、たとえば、私は2ページを参照したいとのリンクは次のようになります。ordonateページ番号codeigniter
if($this->uri->segment($config['uri_segment']))
{
$offset = $this->uri->segment($config['uri_segment']);
$segment_to_replace = $this->uri->segment(2);
$new_id = $this->uri->segment(2)/9 +1;
$new_url = str_replace ($segment_to_replace, $new_id, current_url());
redirect($new_url);
}
しかし、コードが動作していない:localhost/page/9
と3ページは、私はこの機能を試してみてくださいlocalhost/page/18
なります。 最初にvar_dup($new_url)
localhost/page/2を返し、redirect($new_url)
を返します。localhost/page/1.222222222を返します。 もう1つの問題は、連続的なリダイレクトです。どうすれば私のコードのオフセットではなく、curentページを表示するURLを作ることができます。
COMPLETE CODE:デフォルトでは
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/page/';
$config['total_rows'] = $this->product_model->count('active');
$config['per_page'] = 9;
$config['num_links'] = 3;
$config['uri_segment'] = 2;
$config['cur_tag_open'] = ' <b>';
$config['prev_link'] = 'Previous';
$config['next_link'] = 'Next';
$this->pagination->initialize($config);
if($this->uri->segment($config['uri_segment']))
{
$offset = $this->uri->segment($config['uri_segment']);
$segment_to_replace = $this->uri->segment(2);
$new_id = $this->uri->segment(2)/9 +1;
$new_url = str_replace ($segment_to_replace, $new_id, current_url());
var_dump($new_url); die;
return redirect($new_url);
}
tnx man !!救いなさい! – RedoColor
乾杯。ハッピーコーディング。 :) – Tpojka