Welcome Guest, Not a member yet? Register   Sign In
Help with controllers
#1

[eluser]tlam[/eluser]
My current web site without CI has the following structure:

localhost/admin/
localhost/admin/signin/
localhost/admin/signin/youraccount/
localhost/admin/signin/forgotpassword/
localhost/admin/module1/
(...)
localhost/admin/module10/
localhost/admin/misc1/
(...)
localhost/admin/misc5/

From what I have seen so far in CI, the uri is very dependent on the controllers. I can duplicate the above with a controllers/admin.php but it will become a very large controller file. In the future, more modules will be added and the size can be quite huge. Is that how controllers are used in real life CI web sites?

For the case of the signin, how can I replicate the following uri in a controller:
localhost/admin/signin/
localhost/admin/signin/youraccount/
localhost/admin/signin/forgotpassword/

The only clean way of implementing admin is to attach it for each module. For instance:
controllers/module1.php will contain an admin() function. The problem is that the uri for the admins will look like the following:

localhost/module1/admin/
localhost/module2/admin/

Is there an even better way to do all the above, I'm looking for something similar to the admin interface and infrastructure of Django.
#2

[eluser]pistolPete[/eluser]
Create a subfolder called "admin" in application/controllers and put your admin controllers (e.g. "signin", "module1", etc.) there.
You then access them using:

http://domain.com/admin/signin/
http://domain.com/admin/module1/
#3

[eluser]tlam[/eluser]
I have a page under http://localhost/admin/ which shows me the different modules I can administer. How should I write my controller under the admin folder so that it points to http://localhost/admin/
#4

[eluser]pistolPete[/eluser]
Use URI Routing:

Create a controller called main (for example) in application/controllers/admin which lists the different modules.
Add this route to application/config/routes.php:
Code:
$route['admin'] = 'admin/main';
#5

[eluser]Mike Ryan[/eluser]
-- Edit - took too long to post, redundant info :-) --




Theme © iAndrew 2016 - Forum software by © MyBB