CodeIgniter Forums
Pagination error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Pagination error (/thread-40813.html)



Pagination error - El Forum - 04-19-2011

[eluser]Thiago Leao[/eluser]
my pager is giving the following error.
Not getting the bold lyrics that I'm just one page.
And the first page, is not as link.

1 2 3 >


controller

Code:
function listar($id_user, $offset=''){

        if($id_user != $this->session->userdata('loggedin')){
            redirect(base_url().'administracao/home/logout', 'refresh');            
        }else{
            
            $param['titulo'] = 'Catalogo Collection - Administração!';
            
            $this->load->model('categoria_model');
            $this->load->model('administracao/cad_produto_model');            
            
            $maximo = 2;
            $inicio = $this->uri->segment(4,0);
    
            $config['base_url']         = base_url() .'administracao/cad_produto/listar/'.$id_user.'/';
            $config['total_rows']         = $this->cad_produto_model->contaRegistros($id_user);
            $config['per_page']         = $maximo;
            
            $this->pagination->initialize($config);    
            
            $param['paginacao']         = $this->pagination->create_links();
            $param['total_registro']     = $this->cad_produto_model->contaRegistros($id_user);
            $param['produtos']             = $this->cad_produto_model->listar($maximo, $offset, $id_user);
            $param['listar_category']     = $this->cad_produto_model->filtrarBusca($id_user, $maximo, $inicio);
        
            $this->load->view('administracao/list_produto', $param);    
            
        }
    }

model

Code:
function filtrarBusca($id_user, $maximo, $inicio){        
        
        $this->db->select('*');
        $this->db->from('products');
        $this->db->join('category', 'products.id_category = category.id_category', 'inner');
        $this->db->where('products.id_user', $id_user);
        $this->db->limit($maximo, $inicio);
        
        $query = $this->db->get();
        return $query->result();    
        
    }

anywhere help?
thanks


Pagination error - El Forum - 04-19-2011

[eluser]InsiteFX[/eluser]
Your missing this!
Code:
$config['uri_segment'] = 4;

InsiteFX


Pagination error - El Forum - 04-19-2011

[eluser]Thiago Leao[/eluser]
did not work!!

Code:
function listar($id_user, $offset=''){

        if($id_user != $this->session->userdata('loggedin')){
            redirect(base_url().'administracao/home/logout', 'refresh');            
        }else{
            
            $param['titulo'] = 'Catalogo Collection - Administração!';
            
            $this->load->model('categoria_model');
            $this->load->model('administracao/cad_produto_model');            
            
            $maximo = 2;
            $inicio = $this->uri->segment(4,0);
            
            $config['uri_segment']         = 4;  
    
            $config['base_url']         = base_url() .'administracao/cad_produto/listar/'.$id_user.'/';
            $config['total_rows']         = $this->cad_produto_model->contaRegistros($id_user);
            $config['per_page']         = $maximo;
            
            $this->pagination->initialize($config);    
            
            $param['paginacao']         = $this->pagination->create_links();
            $param['total_registro']     = $this->cad_produto_model->contaRegistros($id_user);
            $param['produtos']             = $this->cad_produto_model->listar($maximo, $offset, $id_user);
            $param['listar_category']     = $this->cad_produto_model->filtrarBusca($id_user, $maximo, $inicio);
        
            $this->load->view('administracao/list_produto', $param);    
            
        }
    }



Pagination error - El Forum - 04-19-2011

[eluser]InsiteFX[/eluser]
Pagination Tutorial

InsiteFX


Pagination error - El Forum - 04-19-2011

[eluser]Thiago Leao[/eluser]
did not work!
was actually what I said paging "works" but there's no turning
Go to Page 1, and she gets bold!

thanks


Pagination error - El Forum - 04-19-2011

[eluser]InsiteFX[/eluser]
Quote:did not work!
was actually what I said paging “works” but there’s no turning
Go to Page 1, and she gets bold!

What do you mean by the above? If page 1 is bold then page 1 is the selected page!

Code:
$config['first_link'] = 'First';

CodeIgniter User Guide - Pagination Class

InsiteFX


Pagination error - El Forum - 04-19-2011

[eluser]Thiago Leao[/eluser]
nothing appears, only appears: 1 2 3>

Code:
$inicio = $this->uri->segment(4,0);
            
            $config['uri_segment']         = 4;  
    
            $config['base_url']         = base_url() .'administracao/cad_produto/listar/'.$id_user.'/';
            $config['total_rows']         = $this->cad_produto_model->contaRegistros($id_user);
            $config['per_page']         = $maximo;
            $config['first_link']         = 'First';



Pagination error - El Forum - 04-19-2011

[eluser]InsiteFX[/eluser]
There are other options to the first link that's why I said to read the User Guide!

InsiteFX


Pagination error - El Forum - 04-19-2011

[eluser]Thiago Leao[/eluser]
but I do not know what to do, I read the paging class!

http://ellislab.com/codeigniter/user-guide/libraries/pagination.html


Pagination error - El Forum - 04-20-2011

[eluser]Thiago Leao[/eluser]
I discovered that the fact that a bold stand, is because of the $ cur_page!
He's like $ cur_page = 0, but the one that is getting checked, what do I do?
thanks!