Closed hengkiardo closed 11 years ago
You need to do it like this:
$this->data['users'] = $this->ion_auth->users()->limit($config['per_page'])->offset($this->uri->segment(4))->result();
Hai Ben,
i try to use like you tell, but still not working.
the results still give all records from the table user.
What happens if you manually set the limits, something like this:
$this->data['users'] = $this->ion_auth->users()->limit(2)->offset(1)->result();
still same :(
hi ben,
how to fix that?
How many users do you have?
I used something like:
$config['base_url'] = base_url().'/admin/user';
$config['total_rows'] = $this->ion_auth->users()->num_rows();
$config['per_page'] = '30';
$the_uri_segment = 3;
$config['uri_segment'] = $the_uri_segment;
$this->data['users'] = $this->ion_auth->offset($this->uri->segment($the_uri_segment))->limit($config['per_page'])->users()->result();
foreach ($this->data['users'] as $k => $user)
{
$this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
}
and I've been able to paginate my users.
@jacobkball thanks so bro, now its works
Thanks @jacobkball!
how did you generate the pagination links???
i have code controller :
public function index()
{
$this->load->helper('file');
$this->load->helper('form');
$this->load->helper('url');
if (!$this->ion_auth->logged_in())
{
redirect('dashboard/login', 'refresh');
}
elseif (!$this->ion_auth->is_admin())
{
return show_error('You must be an administrator to view this page.');
}
else
{
$config = array();
$this->load->library('pagination');
$config['base_url'] = base_url('manager_user');
$config['total_rows'] = $this->ion_auth->users()->num_rows();
$config['per_page'] = '2';
$config['num_links'] = 10;
$the_uri_segment = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$config['uri_segment'] = $the_uri_segment;
$this->pagination->initialize($config);
$data['users'] = $this->ion_auth->offset($this->uri->segment($the_uri_segment))->limit($config['per_page'])->users()->result();
foreach ($data['users'] as $k => $user)
{
$data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
}
$data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$data['links'] = $this->pagination->create_links();
$name =$username = $this->session->userdata( 'username' );
$data['subview'] = 'views/manager_user/index';
$data['title'] = 'Manager user';
$data['username']=$name;
$this->load->view('template/layout',$data);
but, moving to the next page, the error Warning: include(D:\xamp\htdocs\CI_demo\application\errors\html\error_php.php): failed to open stream: No such file or directory in D:\xamp\htdocs\CI_demo\system\core\Exceptions.php on line 269 thanks
How is this related to Ion Auth library? Please use discussion forums for this. On Dec 5, 2014 12:33 PM, "vosydao" notifications@github.com wrote:
i have code controller :
public function index()
{ $this->load->helper('file'); $this->load->helper('form'); $this->load->helper('url');
if (!$this->ion_auth->logged_in()) { redirect('dashboard/login', 'refresh'); } elseif (!$this->ion_auth->is_admin()) { return show_error('You must be an administrator to view this page.'); } else { $config = array(); $this->load->library('pagination'); $config['base_url'] = base_url('manager_user'); $config['total_rows'] = $this->ion_auth->users()->num_rows(); $config['per_page'] = '2'; $config['num_links'] = 10; $the_uri_segment = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $config['uri_segment'] = $the_uri_segment; $this->pagination->initialize($config); $data['users'] = $this->ion_auth->offset($this->uri->segment($the_uri_segment))->limit($config['per_page'])->users()->result(); foreach ($data['users'] as $k => $user) { $data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); } $data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); $data['links'] = $this->pagination->create_links(); $name =$username = $this->session->userdata( 'username' ); $data['subview'] = 'views/manager_user/index'; $data['title'] = 'Manager user'; $data['username']=$name; $this->load->view('template/layout',$data);
but, moving to the next page, the error Warning: include(D:\xamp\htdocs\CI_demo\application\errors\html\error_php.php): failed to open stream: No such file or directory in D:\xamp\htdocs\CI_demo\system\core\Exceptions.php on line 269 thanks
— Reply to this email directly or view it on GitHub https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/347#issuecomment-65766158 .
I want to ask, how do you restrict access to the admin user pages member. For example, I logged in admin page ... but I try to access the page the user can direct members to access without a password, i wants when I click page of my members do not have access to it
Just check their group and handle the logic appropriately.
yess this work for me.
$this->load->library('pagination');