CodeIgniter Forums

Full Version: Pagination: Current Page / Back Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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);
}

El Forum

[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,
    );

El Forum

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

El Forum

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

El Forum

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