在我的用户索引页面上,我正在尝试设置CI分页。但是当我点击第二个链接时会加载错误页面“无法加载页面”;我花了一整天时间,不会加载到同一页。我用hmvc我不确定是否会影响它?
如何将其加载到同一页面上。就像我看过的大多数教程一样。喜欢tuts和教程。
$ config ['base_url'] = 'http://localhost/codeigniter-project/';
网址 http://localhost/codeigniter-project/admin/users/
路线 $route['admin/users'] = "admin/user/users/index";
控制器
<?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);
}
}
查看
<?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">' . "User ID" . '</td>';
echo '<td class="text-center">' . "Username" . '</td>';
echo '<td class="text-center">' . "Status" . '</td>';
echo '<td class="text-center">' . "Date Added" . '</td>';
echo '<td class="text-center">' . "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">' . $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');?>
答案 0 :(得分:0)
我刚刚遇到脑风暴,并添加$route['admin/users/(:num)'] = "admin/user/users/index/$1";
,现在链接工作。