I am playing around Codeignter and was curious about the structure of the application:
-
I am not sure when to use the model ( apparently it isnt a hard requirement)
-
I have a part of the header that is dynamic, so I run conditional statements (
if () {..} else {..}) for the sake of code cleanness and clarity. Should I turn that part into a helper and refer to it instead? Or does that sound like too much of a stretch?
The models are best used for data gathering and formatting methods. Such as polling the database for blog posts and then creating post objects of them and returning them.
Then the controller uses them to fill views with the data desired, such as a title, a date, an author, and a shortened body summary.
As far as the header part, consider creating smaller views to encapsulate complex code, like a menu highlighter switch or ifs, away from more clear-cut code. Consider over-building those views. Nothing wrong with creating a view just for one tab on a menu, then calling it 10 times with different data for each of the menu items in another view.
While it seems silly for a menu, it becomes indispensable for uses like boxes to wrap widgets in, or built-in validation on a textarea view.