Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to do multiple pagination on one page in codeigniter

I have seen a number of old posts around this topic on stack overflow but none of them seem to give any clarity. What I have understood by going through them is that codeigniter doesnt support multiple paginations through its class and that you have to write your own class.

I wonder if that is the case. In case any body here has an idea about how to do it please let me know. I have three lists which I'm passing into the view. However when I paginate all of them, all the three lists response to same page offset. Is Ajax_pagination the way out?

Please suggest how to do this.

UPDATE: Here is my code and what I'm trying to do.This is a view file. I have two lists 1. org_list 2. Ind_list I'm trying to pass to these two lists in tow view files (organization_listing, individual_listing) both of which are loaded in this view file and therefore appear on the same page. Now I can paginate one list but when I paginate the second file they both respond to same uri offset.

I'm generating the pagination links in the (organization_listing, individual_listing) view files.

<?php 

    $config['base_url'] = 'http://localhost/socialinew/user_registration/index.php/members_area/view_members_area';
    $config['total_rows'] = count($org_list);
    $config['per_page'] = 4;
    $config['num_links'] = 20;
    $config['full_tag_open'] = '<div id="pagination3">';
    $config['full_tag_close'] = '</div>';

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

    for($i=$this->uri->segment(3)+0;$i<(($this->uri->segment(3)+$config['per_page']));$i++)
    {
        if(isset($org_list[$i]))
        {$temp_org[$i]=$org_list[$i];
        }


    }

    $tmp_org['org_list']=$temp_org;


$this->load->view('organization/organization_listing',$tmp_org);



    $org_config['base_url'] = 'http://localhost/socialinew/user_registration/index.php/members_area/view_members_area/';
    $org_config['total_rows'] = count($ind_list);
    $org_config['per_page'] = 5;
    $org_config['num_links'] = 20;
    $org_config['full_tag_open'] = '<div id="pagination2">';
    $org_config['full_tag_close'] = '</div>';

    $this->pagination->initialize($org_config);

    for($i=$this->uri->segment(4)+0;$i<(($this->uri->segment(4)+$config['per_page']));$i++)
    {
        if(isset($ind_list[$i]))
        {$temp_ind[$i]=$ind_list[$i];
        }
    }

        $tmp_ind['ind_list']= $temp_ind;    

$this->load->view('individual_listing',$tmp_ind);?>

like image 481
yash Avatar asked Nov 03 '22 21:11

yash


2 Answers

If you want

1 2 3 4

 results

1 2 3 4

 results

I'm fairly certain it's pretty straight forward:

  1. just configure for the first set (say to use uri segment 3)
  2. Initialize the pagination
  3. Create the links; and
  4. Send it to the view.

Then

  1. Configure for the second set (say to use uri segment 4)
  2. Initialize the pagination
  3. Create the links; and
  4. Send it to the view.
like image 110
MikeCruz13 Avatar answered Nov 09 '22 05:11

MikeCruz13


Guys I have finally used javascript to load my individual paginations into the page, so I'm sending my paginations into three different views and then using javascript to call those views into the page. Couldnt figure out any way to do multiple paginations on the same page.

like image 34
yash Avatar answered Nov 09 '22 05:11

yash