何时使用模型或帮助器

I am playing around Codeignter and was curious about the structure of the application:

  1. I am not sure when to use the model ( apparently it isnt a hard requirement)

  2. 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.

I am not sure when to use the model ( apparently it isnt a hard requirement)

Models are part of the MVC structure. I'd recommend you to read about it.

I have part of the header that are dynamic, 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?

This article explains you how to use: Helpers in CodeIgniter.

You should use a model if you're reading/writing data to a database (or another data source).

You should use a helper to help you with reusable tasks. For example, you may have an authentication helper, or a form helper, etc.

I would have thought you'd be able to extend a helper to return a random header image URL you can use in an img tag, although it's been a while since I've working with CodeIgniter.