[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">
<?php if ($this->session->flashdata('error')) { ?>
<div class="alert alert-danger"><i class="fa fa-times-circle"></i> <?php echo $this->session->flashdata('error');?></div>
<?php } ?>
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $this->session->flashdata('success');?></div>
<?php } ?>
</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"><?php echo $heading_title; ?></h3></div>
<div class="panel-body">
<?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>';
?>
</div><!-- . Panel Panel-Body -->
</div><!-- . Panel Panel-Default -->
</div><!-- . Columns -->
</div><!-- . Row -->
</div><!-- . Container-fluid-->
</div><!-- #Content -->
<?php echo Modules::run('admin/common/footer/index');?>