CodeIgniter Forums
When to code in controller and when in views? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: When to code in controller and when in views? (/showthread.php?tid=7754)



When to code in controller and when in views? - El Forum - 04-21-2008

[eluser]codeamanny[/eluser]
I have a Table which is being generated by my app.

Should looping through the data be done on the views side of the app?

or is it better to loop on the controller side and pass the resulting data plus html to the view as a variable?

Is there a good way of deciding which is the best way to implement for CI?


When to code in controller and when in views? - El Forum - 04-21-2008

[eluser]xwero[/eluser]
It is up to you, there is no good or bad way. Personally i like to keep all my html code in view files because then designers can see all the html but this means there is quite some code in the view files.


When to code in controller and when in views? - El Forum - 04-21-2008

[eluser]codeamanny[/eluser]
CI is really beautiful when you have a view file like

echo $beginform
echo $table (with form elements dynamically generated inside (WOW!)
echo $endform

SCREW the designers..., they don't mess with my masterpiece!....... Wink

I think I fell madly in love with CI tonight.. Its not perfect, but its got a lot of promise.


When to code in controller and when in views? - El Forum - 04-22-2008

[eluser]xwero[/eluser]
As long as you don't take CI to bed you'll be fine :lol:


When to code in controller and when in views? - El Forum - 04-22-2008

[eluser]adwin[/eluser]
I use CI combined with Freakauth and Smarty ... so simple and so wonderfull ...
I did all the logic in controller and all the beauty thing in views with Smarty Wink (actually i replace views with smarty code) I use smarty instead of pure php code so that my designer can work with it.