[英]How to make a proper index page for subdirectories in CodeIgniter
I'm building an app that has a section for consumers and businesses, and I want to separate the controllers folder appropriately, so it looks like this - 我正在构建一个针对消费者和企业的版块的应用,并且我想适当地分隔controllers文件夹,所以它看起来像这样-
http://domain.com/users/signup/
http://domain.com/business/signup/
I have it working by creating a separate folder for each section in the "controllers" folder, but I want to know how to make an appropriate page when the user visits the http://domain.com/users/ . 我通过为“ controllers”文件夹中的每个部分创建一个单独的文件夹来使其工作,但是我想知道当用户访问http://domain.com/users/时如何制作适当的页面。 It currently just loads the homepage.
当前它仅加载主页。 How can I fix this?
我怎样才能解决这个问题?
You don't need to put them in separate folders for this to work. 您无需将它们放在单独的文件夹中即可工作。
File system/application/controllers/users.php: 文件系统/应用程序/控制器/users.php:
<?php
class Users extends Controller {
function index() {
// this function will be called at http://domain.com/users
}
function signup() {
// this function will be called at http://domain.com/users/signup
}
}
?>
File system/application/controllers/business.php: 文件系统/应用程序/控制器/business.php:
<?php
class Business extends Controller {
function index() {
// this function will be called at http://domain.com/business
}
function signup() {
// this function will be called at http://domain.com/business/signup
}
}
?>
If I understand your question correct, you might be looking for URI Routing . 如果我对您的问题的理解正确,那么您可能正在寻找URI路由 。 I don't see why you would need folders for this.
我不明白为什么您需要为此使用文件夹。 Simply just create the routes you need and make use of the index methods in the controllers for making the "homepage" for both users and business.
只需创建所需的路由并利用控制器中的索引方法为用户和企业创建“主页”即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.