Welcome Guest, Not a member yet? Register   Sign In
Keeping models out of views - applying a function to a result array
#3

[eluser]TheFuzzy0ne[/eluser]
Hi, Matt!

There are no rules against making calls to models in your views, but some people (like myself) to prefer avoid it, since technically $this just happens to link to the CodeIgniter super object (as the view is processed within it's scope). I think that what's considered bad practice is using $this within your view.

If I were in your position, I'd export the formatting method to a helper, and use that. format($some_data) looks nicer to me than $this->some_model->format($some_data), but that's just my personal preference. Of course, if you're only calling on this method from within a loop, it shouldn't really make any difference.


Messages In This Thread
Keeping models out of views - applying a function to a result array - by El Forum - 07-09-2009, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB