在Codeigniter中设置管理面板 [英] Setting up admin panel in Codeigniter
问题描述
在我的项目中,我试图为管理员创建一个区域.遵循 http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter#top 我尝试了第二种方法.据此,我的文件夹结构更改为如下所示.
In my project I am trying to create one section for admin. Following http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter#top I tried the second method. According to it, my folder structure is changed to somewhat like this.
project
cache
config
controllers
-admin
index.php
-blog.php
system
views
-admin
index.php
blog.php
...................
我在 controllers/admin 内用以下代码创建了一个控制器 index.php :
I have created one controller index.php inside controllers/admin with following code:
class Index extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view(index/index);
}
}
在 views/admin 中,我创建了一个文件 index.php 并回显了一些字符串,并在 routes.php 中添加了此文件线,
And inside views/admin I have created a file index.php and echoed some string and in routes.php I have added this line,
$route['admin'] = 'admin/index';
但是当我使用URL http://localhost/workspace/project/admin/
运行管理面板时,出现了404错误
But when I run the admin panel using the url, http://localhost/workspace/project/admin/
, I am getting the 404 error
The requested URL /workspace/project/admin/ was not found on this server.
我做错了什么?我还需要进行其他设置吗?
What I am doing wrong? Is there any other settings I have to make.
有人可以指导我解决此问题吗?我是Codeigniter的新手.
Can someone please guide me to fix this ? I am new to Codeigniter.
谢谢.
推荐答案
更改文件结构(您需要在admin.php控制器中创建索引函数)
let change your files structure (You need to create an index function in your admin.php controller)
project(may be root folder of CI)
applications
cache
config
controllers
-admin
index.php (method index)
-blog.php
system
views
-admin
index.php
blog.php
还将控制器名称更改为admin并查看负载
also change controller name to admin and view load
class Index extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('admin/index');
}
}
然后更改您的路线
$route['admin'] = 'admin/index';
这篇关于在Codeigniter中设置管理面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!