Welcome Guest, Not a member yet? Register   Sign In
How can I get rid of this logic from the view?
#6

[eluser]Aken[/eluser]
If you're going to separate the logic that generates the views into a view_things() method, you should make it private or put an underscore on the front, otherwise it can be called through the browser.

Code:
private function view_things() {}
// OR
function _view_things() {}

Otherwise that's a perfect starting point. Basically, if you find yourself doing logic, like comparisons or checking for empties, in your view, you can do it in your controller instead if you want to keep the code clean. Doing some logic is okay, it can just get really complicated to read if you have a lot. That's where template scripts like Smarty and Twig come in handy. Or, if you're just echoing variables, you can use CI's Parser library instead of doing a ton of opening/closing PHP tags.


Messages In This Thread
How can I get rid of this logic from the view? - by El Forum - 01-27-2013, 07:52 PM
How can I get rid of this logic from the view? - by El Forum - 01-27-2013, 08:23 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 07:00 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 07:06 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 07:23 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 07:28 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 07:55 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 08:24 PM
How can I get rid of this logic from the view? - by El Forum - 01-31-2013, 08:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB