Welcome Guest, Not a member yet? Register   Sign In
Multiple Pagination
#1

On my index I need to pagination one for users list and one for forum questions.

The pagination links are not working seperate they seem to be working insink with each other.

Even though the config named diffetent? Any ideas what I need to do?


Code:
<?php

class Dashboard extends MY_Controller {

public $data = array();

public function __construct() {
parent::__construct();
$this->load->library("pagination");
$this->load->model('user/user_model');
$this->load->model('forum/question_model');
}

public function index() {
$this->data['title'] = 'Dashboard';
$this->data['is_logged'] = $this->session->userdata('is_logged');

$config1 = array();

$config1['full_tag_open'] = "<ul class='pagination'>";
$config1['full_tag_close'] ="</ul>";
$config1['num_tag_open'] = '<li>';
$config1['num_tag_close'] = '</li>';
$config1['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config1['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config1['next_tag_open'] = "<li>";
$config1['next_tagl_close'] = "</li>";
$config1['prev_tag_open'] = "<li>";
$config1['prev_tagl_close'] = "</li>";
$config1['first_tag_open'] = "<li>";
$config1['first_tagl_close'] = "</li>";
$config1['last_tag_open'] = "<li>";
$config1['last_tagl_close'] = "</li>";
$config1["base_url"] = base_url('dashboard/users/');
$config1["total_rows"] = $this->user_model->total_users();
$config1["per_page"] = 1;
$config1["uri_segment"] = 3;
$config1['use_page_numbers'] = FALSE;

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

$userspage = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

$this->data['users'] = array();

$users = $this->user_model->get_users($config1["per_page"], $userspage);

foreach ($users as $user) {
$this->data['users'][] = array(
'user_id' => $user['user_id'],
'username' => $user['username'],
'status' => ($user['status']) ? 'Enabled' : 'Disabled',
'warning' => '0' . '%',
'date' => date('d-m-Y H:i:s A', $user['date_created_on']),
'href' => site_url('user/profile/') . $user['user_id']
); 
}

$this->data["pag1_links"] = $this->pagination->create_links();

$config2 = array();

$config2['full_tag_open'] = "<ul class='pagination'>";
$config2['full_tag_close'] ="</ul>";
$config2['num_tag_open'] = '<li>';
$config2['num_tag_close'] = '</li>';
$config2['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config2['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config2['next_tag_open'] = "<li>";
$config2['next_tagl_close'] = "</li>";
$config2['prev_tag_open'] = "<li>";
$config2['prev_tagl_close'] = "</li>";
$config2['first_tag_open'] = "<li>";
$config2['first_tagl_close'] = "</li>";
$config2['last_tag_open'] = "<li>";
$config2['last_tagl_close'] = "</li>";
$config2["base_url"] = base_url('dashboard/questions/');
$config2["total_rows"] = $this->question_model->total_questions();
$config2["per_page"] = 1;
$config2["uri_segment"] = 3;
$config2['use_page_numbers'] = FALSE;

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

$question_page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

$questions = $this->question_model->get_questions($config2["per_page"], $question_page);

$this->data['questions'] = array();

foreach ($questions as $question) {
$this->data['questions'][] = array(
'user_id' => $question['user_id'],
'title' => $question['title']
);
}

$this->data["pag2_links"] = $this->pagination->create_links();

$this->data['navbar'] = $this->load->view('common/navbar', $this->data, TRUE);
$this->data['header'] = $this->load->view('common/header', $this->data, TRUE);
$this->data['footer'] = $this->load->view('common/footer', '', TRUE);
 
$this->load->view('common/dashboard', $this->data);

}
}


Attached Files
.php   Dashboard.php (Size: 3.56 KB / Downloads: 129)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

Create a new pagination class instance with the loading method aliasing function and try that way...
$this->load->library(name, params, alias)
Reply
#3

(04-22-2017, 10:50 PM)orionstar Wrote: Create a new pagination class instance with the loading method aliasing function and try that way...
$this->load->library(name, params, alias)

unsure how to do that
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

(This post was last modified: 04-23-2017, 08:41 AM by InsiteFX. Edit Reason: Fixed editing mistake. )

PHP Code:
$this->load->library('pagination''''pagination1');
$this->pagination1->initialize($config1);

$this->load->library('pagination''''pagination2');
$this->pagination2->initialize($config2); 

Give that a try not sure if it is correct.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 04-23-2017, 07:47 AM by orionstar.)

(04-23-2017, 03:07 AM)InsiteFX Wrote:
PHP Code:
$this->load->library('pagination''''pagination1');
$this->pagination->initialize($config1);

$this->load->library('pagination''''pagination2');
$this->pagination->initialize($config2); 

Give that a try not sure if it is correct.

PHP Code:
$this->load->library('pagination''''pagination1');
$this->pagination1->initialize($config1);

$this->load->library('pagination''''pagination2');
$this->pagination2->initialize($config2); 

You have to use the alias to acces the newly created objects...
Reply
#6

(04-23-2017, 03:07 AM)InsiteFX Wrote:
PHP Code:
$this->load->library('pagination''''pagination1');
$this->pagination1->initialize($config1);

$this->load->library('pagination''''pagination2');
$this->pagination2->initialize($config2); 

Give that a try not sure if it is correct.

Thank you will try it.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#7

(This post was last modified: 04-23-2017, 03:53 PM by wolfgang1983.)

Still not working only seems to work with one pagination not multiple on one page
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB