CodeIgniter Forums
Pagination: Current Page / Back Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Pagination: Current Page / Back Problem (/showthread.php?tid=21529)



Pagination: Current Page / Back Problem - El Forum - 08-12-2009

[eluser]weetstraw[/eluser]
I'm having an issue using pagination. The current page of results does not go bold, it stays at 1. In addition, I do not get a back arrow. Below is my controller, any ideas?

I do get the right number of results per page and the results do change when I click 2, 3, etc...

Thanks in advance!

Code:
function discipline()
{
    $dis = $this->uri->segment(3);
    $offset = $this->uri->segment(4);
    $row= $this->Project_model->disciplineCount($dis);
    
    // Pagination
    $config=array(
        'base_url'         => base_url()."projects/discipline/".$dis,
        'total_rows'     => $row->total,
        'per_page'         => 12,
        'num_links'        => 10
    );
    $this->pagination->initialize($config);
    
    $data = array(
        'subTitle'         => ' - Projects',
        'css'             => array('projects'),
        'js'             => NULL,
        'menu'             => 'projects',
        'id'             => NULL,
        'dis'             => $dis,
        'switch'         => $this->Project_model->projectDiscipline($dis,$config['per_page'],$this->uri->segment(4)),
        'categories'     => $this->Project_model->category(),
        'disciplines'     => $this->Project_model->discipline($dis),
        'pagination'    => $this->pagination->create_links(),
        'boxes'         => array('projects-category','projects-discipline')
        );
    
    $this->load->view('project_view.php', $data);
}



Pagination: Current Page / Back Problem - El Forum - 08-12-2009

[eluser]pistolPete[/eluser]
The offset seems to be stored in the 4th uri segment but the default configuration is:
Code:
/* Location: ./system/libraries/Pagination.php */
/* Line number 38 */
var $uri_segment = 3;

You should change your configuration:

Code:
// Pagination
    $config=array(
        'base_url'         => base_url()."projects/discipline/".$dis,
        'total_rows'     => $row->total,
        'per_page'         => 12,
        'num_links'        => 10,
        'uri_segment'        => 4,
    );



Pagination: Current Page / Back Problem - El Forum - 08-12-2009

[eluser]weetstraw[/eluser]
Perfect, thanks!


Pagination: Current Page / Back Problem - El Forum - 03-06-2011

[eluser]runrun[/eluser]
I got the same problem today, was about to post a topic then find this. Thanks guys!


Pagination: Current Page / Back Problem - El Forum - 01-15-2014

[eluser]Unknown[/eluser]
Thanks this solved my problem too Smile