0

我的 CI 有问题。我正在使用 CI 分页,但是当我到达第 2/3 页时……第一页仍然被标记。 每次我更改页面时,内容也会更改,但第一页仍然标记为 1 功能 URL 是:

uri->segment(4) www.site.com/controller/function/index/1(页码)

功能 :

$this->load->helper("url");
        $limite = 6;
        if ($this->uri->segment(4) == ""):
            $data['start'] = 0;
        else:
            $data['start'] = $this->uri->segment(4);
            $data['start'] = ($data['start']-1)*$limite;
        endif;

        //Carregar a livraria paginação
        $this->load->library('pagination');
        //URL Base
        $config['base_url']     =   base_url().'item_shop/armaduras/index/';
        //Total de registos
        $config['total_rows']   =   $this->item_shop_model->contar_armaduras($limite,$data['start']);
        //Numero de links
        $config['num_links']    =   5;
        // Segmento que conterá o parâmetro de incremento
        $config['uri_sigments'] =   3;
        $config['per_page']     =   $limite;
        $config['first_page']   =   1;

        // Configuracoes de estilo da url
        $config['first_link'] = '<<';
        $config['last_link'] = '>>';
        $config['next_link'] = '>';
        $config['prev_link'] = '<';
        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span>';
        $config['use_page_numbers'] = TRUE;     

        // Iniciamos as configuracoes e criamos o link para o acesso
        $this->pagination->initialize($config);
        $data['pagination']     =   $this->pagination->create_links();
        $data['items']          =   $this->item_shop_model->select_all_armaduras($limite,$data['start']);
        $data['title']          =   "HeroM2 Servidor Privado de Metin2";
        $this->load->view('shop-2',$data);

当我使用索引功能控制器时,它工作得很好:

uri->segment(3) www.site.com/controller/index/1

索引功能:

$this->load->helper("url");
        //Limite de registos
        $limite = 6;
        if ($this->uri->segment(3) == ""):
            $data['start'] = 0;
        else:
            $data['start'] = $this->uri->segment(3);
            $data['start'] = ($data['start']-1)*$limite;
        endif;

        //Carregar a livraria paginação
        $this->load->library('pagination');
        //URL Base
        $config['base_url']     =   base_url().'item_shop/index/';
        //Total de registos
        $config['total_rows']   =   $this->item_shop_model->contar_espadas($limite,$data['start']);
        //Numero de links
        $config['num_links']    =   5;
        // Segmento que conterá o parâmetro de incremento
        $config['uri_sigments'] =   3;
        $config['per_page']     =   $limite;
        $config['first_page']   =   1;

        // Configuracoes de estilo da url
        $config['first_link'] = '<<';
        $config['last_link'] = '>>';
        $config['next_link'] = '>';
        $config['prev_link'] = '<';
        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span>';
        $config['use_page_numbers'] = TRUE;     

        // Iniciamos as configuracoes e criamos o link para o acesso
        $this->pagination->initialize($config);
        $data['pagination']     =   $this->pagination->create_links();
        $data['items'] = $this->item_shop_model->select_all_espadas($limite,$data['start']);
        $data['title'] = "HeroM2 Servidor Privado de Metin2";
        $this->load->view('shop-1',$data);

有人能帮我吗?

4

1 回答 1

0

当 url 是www.site.com/controller/function/index/1配置uri_segment应该是 4

于 2013-10-20T12:05:41.850 回答