Welcome Guest, Not a member yet? Register   Sign In
how do I know which link has been clicked on web page? - CI newbie Q
#6

[eluser]WanWizard[/eluser]
What people usually do, is to create directories in the controllers directory for major functions, for example 'admin'.

Then you could have a members controller in that directory, where the index method would list the defined users, the edit method allows you to edit a user record, the delete method to delete a user, and so on.

From a URL point of view, that would be
Code:
http://www.example.com/admin/members (no method defined, so it would call the index method)
http://www.example.com/admin/members/index (same as above)
http://www.example.com/admin/members/edit/1 (would edit user with ID 1)
http://www.example.com/admin/members/delete/1 (would delete user with ID 1)
Note that from a security point of view, it might not be wise to pass the ID in the URL for the edit or delete methods. It would be better to use a form POST to pass the ID to the controller, and protect the form with a nonce.


One advantage of grouping methods that functionally belong together in a single controller is that they can share private functions and class variables.

There is however nothing against giving every function its own controller. That would give you a lot more controllers to deal with, but each of them will not contain a lot of code, so from a maintenance point of view that might be handy.

There isn't really a set way of working with CI, it all boils down to what you feel the best way is.


Messages In This Thread
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 04:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB