I have been looking at CodeIgniter template systems and all so far, it allows you to change content within the header or footer file, but I am looking for a way to load data in to the header file from a model automatically (dependent on the template).
For example, in my header, it displays the users username and inbox. I need to load the users unread messages from a model and the users username. This is dependent on the template though – I only want to load that information if the user is logged in.
Passing data from model to a view is not a good practice.
You should pass data first to the controller and only then to your view.
http://codeigniter.com/user_guide/overview/appflow.html
As you can see on this application flow chart – there is no straight line between model and view.
If you are interested in displaying model data in your “layout” – use hooks!
http://codeigniter.com/user_guide/general/hooks.html
Define a “pre_controller” hook, get CI instance, load model, retrive data and display it in your layout.
Enable hooks
Define a hook like:
E.g.
Hook
In your layout you can get gamescount value like