Welcome Guest, Not a member yet? Register   Sign In
Whats the best way to display a record count on every page?
#1

[eluser]designcloud[/eluser]
Hello. I am trying to display a record count (number of messages in the users inbox), in the header of each page. Which means I cant use a particular controller/model for this.

Is there a simple way to do this with some kind of global controller + model that can be run on every page? Bare in mind, that the number of messages in the inbox can change at any time if they receive a new one - which makes it difficult to use a session... Im a PHP beginner by the way so if the solution is plain and simple... apologies!
#2

[eluser]kgill[/eluser]
You handle it the exact same way you're putting everything else on the page. Stick the get message count method in your mail model and call it where it's needed. Since you want it on every page rather than type the load model and method call in every controller, use the MY_Controller method and place it there. Read the user guide section on creating core classes and that'll get you started.
#3

[eluser]n0xie[/eluser]
You could also fake it by saving the inbox nr to a session, and just update it once every X requests or X minutes.

Or you could do it by caching the inbox nr and just poll for updates using an ajax call.

Remember that most 'real time' applications online just give you the illusion of real time.
#4

[eluser]designcloud[/eluser]
Great, thanks guys that was a quick response! Will start with the My_controller as it looks like exactly what I need to do.




Theme © iAndrew 2016 - Forum software by © MyBB