Welcome Guest, Not a member yet? Register   Sign In
Confused by senior developer by talk of objects in a view
#3

[eluser]mddd[/eluser]
I think you have to separate form from function here.

The MVC principle means that you try to keep the 'smart bits' of your website (checking if a user is logged in, getting things from the database etc) out of your views. The model is the place to do those things. The view is simply for displaying things.

This is different than saying you should not use objects in your view. There's nothing wrong with that. Just don't be tempted to do complicated things to those objects. If you need to save a password for a user, do it in the model. But if you pass a "user" object from the controller to the view, it's fine to use $user->is_logged_in() to check if the user is logged in. That is not really any different from doing " if ($user_logged_in) { ... } ".


Messages In This Thread
Confused by senior developer by talk of objects in a view - by El Forum - 08-10-2010, 07:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB