我正在为我的网站使用CI。虽然为同一个CMS编程我遇到了没有问题,但是当我为用户端编程相同时,我得到的错误是: “404页面不存在 未找到您所请求的页面。” 我究竟做错了什么??热烈欢迎任何帮助/建议。谢谢。
在Controller(model.phpl)中:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Model extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('user_model');
$this->load->model('common');
$this->load->model('home_model');
$this->load->model('page_model');
}
function _remap($method , $params = array())
{
$this->menu = $this->common->createMenuArr();
$this->index();
}
function index()
{
$data['sliderArr'] = $this->user_model->sliders();
$this->load->view('index', $data);
}
}
在Model(user_model.php)中:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_model extends CI_Model{
function __construct()
{
parent::__construct();
//$this->load->database();
}
function sliders()
{
$query = $this->db->query("SELECT slider FROM tbl_sliders ORDER BY slider_id DESC")->result_array();
return $query;
}
}
最后在视图中(index.php):
<div id="slideContainer">
<div id="slideShim">
<?php
if(!empty($sliderArr))
{
foreach($sliderArr as $slider)
{ ?>
<a href="#"><img src="<?php echo base_url();?>images/sliders/<?php echo $slider['slider'];?>"</a>
<?php }
}
?>
</div>
</div>
答案 0 :(得分:1)
转到应用程序 - &gt;配置 - &gt;路线即可。
并设置$route['default_controller'] = "index"; //whatever your controller name is on which you want your application to route by default
希望这有帮助。