Welcome Guest, Not a member yet? Register   Sign In
Pagination don't work right.
#1

[eluser]setty[/eluser]
I have a problem with pagination.

My code in controller looks like this:

Code:
$config = array();
// Load pagination library
$this->load->library('pagination');
            
// Load required language
$this->lang->load('cc/list');
    
// Pagination configuration            
$config['base_url'] = base_url().$this->lang->lang().'/cc/materials';
$config['total_rows'] = $this->db->count_all('stars');
$config['per_page'] = 25;

// Initialize pagination
$this->pagination->initialize($config);

// Data
$data['task'] = "list";
$data['title'] = $this->lang->line('cc.site.title');
$data['materials'] = $this->stars->get_stars_info($config['per_page'], $this->uri->segment(4));
                
                
$this->load->view('cc/index', $data);

But on page i get something like this

1 2 3 > Last ›

In this navigation i haven't "Previous" link and "First" and when i clicking on numeric links they don't become active and url of link "Next" don't change url and links "Previous" and "First" don't appear.


And please "Research Assistant" don't put in this post your answers from "User guide", it didn't help me.
#2

[eluser]theprodigy[/eluser]
you might want to think about telling it what page you are showing, by setting the cur_page variable.

Also, I'm not entirely sure if it matters, but the User Manual does show the base_url ending with a slash
#3

[eluser]setty[/eluser]
Ending base_url with a slash didn't change situation. Going to see Pagination.php. Hope I will find some solution.
#4

[eluser]theprodigy[/eluser]
did you also set the cur_page variable? It needs to know what records to pull. (ie, page 1 shows 1-10, page 2, 11-20, etc).
#5

[eluser]setty[/eluser]
I solved problem by setting $config['uri_segment'] obviously. now my code looks like:
Code:
$config = array();
// Load pagination library
$this->load->library('pagination');
    
// Load required language
$this->lang->load('cc/list');
                
// Pagination configuration            
$config['base_url'] = base_url().$this->lang->lang().'/cc/materials/';
$config['total_rows'] = $this->db->count_all('stars');
$config['per_page'] = 25;
$config['uri_segment'] = 4;
                
// Initialize pagination
$this->pagination->initialize($config);

// Data
$data['task'] = "list";
$data['title'] = $this->lang->line('cc.site.title');
$data['materials'] = $this->stars->get_stars_info($config['per_page'],$this->uri->segment($config['uri_segment']));
                
$this->load->view('cc/index', $data);

I changed:
Code:
$this->stars->get_stars_info($config['per_page'],$this->uri->segment(4));
For:
Code:
$this->stars->get_stars_info($config['per_page'],$this->uri->segment($config['uri_segment']));




Theme © iAndrew 2016 - Forum software by © MyBB