Welcome Guest, Not a member yet? Register   Sign In
pagination links will not work
#1

[eluser]riwakawd[/eluser]
On my users index page I am trying to set up the CI Pagination. But when I click on the 2nd link will load a error page "Unable to load page"; I have spent all day on it and will not load on the same page. I use hmvc I am not sure if that effects it?

How can I make it load on same page. As what most tutorials I have watched show. Like the tuts plus tutorial.

When click on link 2 url shows http://localhost/codeigniter-project/admin/users/1 but unable to load page.

Code:
$config['base_url'] = 'http://localhost/codeigniter-project/';

URL http://localhost/codeigniter-project/admin/users/

Route $route['admin/users'] = "admin/user/users/index";

Controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends MX_Controller {
public function __construct() {
parent::__construct();
  $this->lang->load('admin/user/users', 'english');
  $this->load->model('admin/user/users_model');

  if (!$this->user->logged()) {
   redirect('admin');
  }
}

public function index() {
$this->document->setTitle($this->lang->line('heading_title'));

$data['heading_title'] = $this->lang->line('heading_title');

$this->load->library('setting');

$this->load->library('pagination');

$config = array();

$config["base_url"] = base_url('admin/users');
$config['total_rows'] = $this->db->get('user')->num_rows();
$config["per_page"] = $this->setting->get('config_limit_admin');
$config["uri_segment"] = 3;  

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

$data['user'] = $this->db->get('user', $config["per_page"], $this->uri->segment(3));


return $this->load->view('user/users_list', $data);
}
}

View

Code:
<?php echo Modules::run('admin/common/header/index');?><?php echo Modules::run('admin/common/column_left/index');?>

<div id="content">
<div class="container-fluid">


<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
&lt;?php if ($this->session->flashdata('error')) { ?&gt;
<div class="alert alert-danger"><i class="fa fa-times-circle"></i> &lt;?php echo $this->session->flashdata('error');?&gt;</div>
&lt;?php } ?&gt;
&lt;?php if ($this->session->flashdata('success')) { ?&gt;
<div class="alert alert-success"><i class="fa fa-check-circle"></i> &lt;?php echo $this->session->flashdata('success');?&gt;</div>
&lt;?php } ?&gt;
</div>
</div>

<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">&lt;?php echo $heading_title; ?&gt;</h3></div>
<div class="panel-body">

&lt;?php  

echo '<div class="table-responsive">';
echo '<table class="table table-striped table-bordered table-hover">';
echo '<thead>';
echo '<tr>';
echo '<td class="text-center"  #1e91cf; font-weight: bolder">' . "User ID" . '</td>';
echo '<td class="text-center"  #1e91cf; font-weight: bolder">' . "Username" . '</td>';
echo '<td class="text-center"  #1e91cf; font-weight: bolder">' . "Status" . '</td>';
echo '<td class="text-center"  #1e91cf; font-weight: bolder">' . "Date Added" . '</td>';
echo '<td class="text-center"  #1e91cf; font-weight: bolder">' . "Action" . '</td>';
echo '</tr>';
echo '</thead>';

foreach ($user->result() as $row) {

echo '<tbody>';
echo '<tr>';
echo '<td class="text-center">' . $row->user_id  .'</td>';
echo '<td class="text-center"  bolder;">' . $row->username  .'</td>';
echo '<td class="text-center">' . $row->status  .'</td>';
echo '<td class="text-center">' . $row->date_added  .'</td>';
echo '<td class="text-center">' . anchor("admin/users/edit/" . $row->user_id, '<div class="btn btn-primary text-right" role="button"><i class="fa fa-pencil"></i>
Edit</div>')  .'</td>';
echo '</tr>';
echo '</tbody>';

}

echo '</table>';
echo '</div>';
echo '<div class="row">';
echo '<div class="col-sm-6 text-left">';
echo $this->pagination->create_links();
echo '</div>';
echo '</div>';

?&gt;

</div>&lt;!-- . Panel Panel-Body --&gt;
</div>&lt;!--  . Panel Panel-Default --&gt;
</div>&lt;!-- . Columns --&gt;
</div>&lt;!-- . Row --&gt;
</div>&lt;!-- . Container-fluid--&gt;
</div>&lt;!-- #Content --&gt;

&lt;?php echo Modules::run('admin/common/footer/index');?&gt;
#2

[eluser]Tpojka[/eluser]
Just on first look seems like you missed to pass an argument for page name:

Code:
$route['admin/users/(:num)'] = "admin/user/users/index/$1";

Code:
public function index($page=false) {
  //rest of code
}
#3

[eluser]riwakawd[/eluser]
I just that figured it out 10min ago i did that what did when edit users $route['admin/users/(:num)'] = "admin/user/users/index/$1"; and now links work.




Theme © iAndrew 2016 - Forum software by © MyBB