Reputation: 6386
do you create a new controller for every page that will be public or just have one controller called , for example, page then have all the pages loaded through methods.
which method is recommended and why?
I'm building a ecommerce/cms application and have created a controller named register where users register a new account and it has about 5 views that get displayed via the methods. All processing such as form validation and payment processing is being done within a model. As far as the controller goes do you see a long term problem with the method i have chosen?
Upvotes: 0
Views: 48
Reputation: 2382
The MVC architecture is letting you to divide portions with controllers and then divide low level parts of that portion with methods. The usual way for me is to first create an Index
controller for my front-end and then separate different parts like users login, users registration, news part, even shopping part to methods. And it's going to be like this:
class Index_Controller extends CI_Controller
{
public function index(){}
public function login(){}
public function register(){}
...
}
Upvotes: 1
Reputation: 2734
Not at all. The controller should contain the methods relevant for the controller. For example Controller : members - methods - login - logout - register - delete - viewprofile
This way you keep a strict order in your mvc and your urls make sence. /members/register. /members/login
Its mostly common to have multiple views in one controller unit.
Best regards Jonas
Upvotes: 0