Welcome Guest, Not a member yet? Register   Sign In
Single value return "Array to string conversion?"
#7

[eluser]Sky Warden[/eluser]
[quote author="jmadsen" date="1364004593"]There are different design patterns, and down the road you might decide you like one of them better. However, one thing I think they all have in common is - we don't load the data directly into the view

In any case, Codeigniter is built around using a controller to strap these together, and when you load models into a view, yo invariably need to add a lot of "presenter" type logic there as well, making a real mess of your code & making it very difficult for others to trace your code & understand it.

The rule of thumb I generally go by is:

If you need to manipulate the data at all (I would include calling it from the data source in this), do it in your controller first & just display

If you are only looking to format data (format your date, capitalize words, etc), you can make a helper function & feel free to call that directly in the view.

That's just my way of doing it, but it works pretty well for me. [/quote]
Yes. That's how I do it most of the time. I usually do data manipulation in the controller, with the help of some models if necessary. Then I warp those data in an array which I send to the view as the second parameter. :lol:


Messages In This Thread
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 03:13 AM
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 03:35 AM
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 03:45 AM
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 03:52 AM
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 04:33 AM
Single value return "Array to string conversion?" - by El Forum - 03-22-2013, 07:09 PM
Single value return "Array to string conversion?" - by El Forum - 03-23-2013, 10:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB