[英]Codeigniter: Index page creation
My folder structure is as following我的文件夹结构如下
admin
__master
_______address_book
_______Users
_______Product
_______etc
__operations
_______register_orders
_______payments
_______etc
I have created controllers for address_book,users,products,register_orders, payments etc to reduce the complexity of each controller.我为 address_book、users、products、register_orders、payments 等创建了控制器,以降低每个控制器的复杂性。
Now, how to handle index page request for www.abc.com/admin ?现在,如何处理www.abc.com/admin 的索引页请求? I have created Admin controller in /controllers directory then other links like www.abc.com/admin/master/address_book will not work.我在 /controllers 目录中创建了 Admin 控制器,然后其他链接如www.abc.com/admin/master/address_book将不起作用。
How to handle both requests?如何处理这两个请求? I would also like to know is there any way to handle each index page requests eg:我还想知道有没有办法处理每个索引页面请求,例如:
www.abc.com/admin/
www.abc.com/admin/master/
www.abc.com/admin/operations/
To access each request with url like-使用 url 访问每个请求,例如 -
www.abc.com/admin/
www.abc.com/admin/master/
www.abc.com/admin/operations/
you have to use codeigniter's
routing.你必须使用codeigniter's
路由。 And for routing there are a config
file under aplication/config
folder named routes.php
.而对于路由有一个config
下的文件aplication/config
文件夹命名routes.php
。 Add all your routes in this file.在此文件中添加所有路由。 Suppose you want to access this url-假设你想访问这个网址——
www.abc.com/admin/operations/
then you have to create a new route for this in the route file
, like-那么你必须在route file
为此创建一个新路由,比如-
$route['admin/operations'] = 'admin/operations';
where in $route
array index you have to mention what will be the url and the value against this index you have to mention the controller's path
and also you can mention the controller's function
name which will be invoked (for index
function there no need for mentioning).在$route
数组索引中,您必须提及该索引的 url 和值,您必须提及控制器的path
,并且您还可以提及将被调用的控制器的function
名称(对于index
函数,无需提及)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.