Confused about URI segments and functions |
[eluser]dallen33[/eluser]
I'm still "new" to this, so bare with me. I'm using DX_Auth and I want the admin to be able to edit users in the backend. So the users function looks like this in the backend controller: Code: function users() http://localhost:8888/index.php/backend/users When that page is loaded, a table is presented with all users and a link to edit a user, which looks like this: http://localhost:8888/index.php/backend/users/edit/1 '1' being the userid. I just don't understand how I build this in the controller. I could easily do another function called edit, but I'd rather keep everything in the users function.
[eluser]Mackstar[/eluser]
That is a long function! I understand what you are trying to do, but as the function becomes even longer you will have even more trouble trying to manage it as each of your commands become too reliant on each other. This ends up turning into Spagetti. Your clean code and well commented syntax is the only thing that is saving you at the moment. I would separate ALL of your actions into separate functions, then any consistent commands that you see in many of your functions you can add as a method in the model where possible or create a local method. The controller needs to be as simple as possible, models need to contain ALL of your data logic. After 2 years heavy MVC usage I have found these techniques to be the most manageable and maintainable. But that is my opinion, and preference. Others may disagree with me, but that is what I would do... CI's controller centric documentation does not bring out MVC's and CI's power. Cheers Richard |
Welcome Guest, Not a member yet? Register Sign In |