Welcome Guest, Not a member yet? Register   Sign In
One method for multiple controllers?


I'm building a site which features some basic community functions, pretty much meaning a simple messaging system. The messaging functionality is up and running, problem is I now want the link to the inbox to reflect wheter or not there are unread messages waiting.

This link is in the header view, which is loaded in every controller. I want it to check for new messages on every page load but I can't figure out how to do that without breaking the MVC model and without having to repeat the same line of code in every controller.

Is a hook at post_controller_constructor a possible solution? I just have a feeling that this is not what is meant by "extending the framwork core".. All suggestions are very much welcome!

Best regards,
Erik Brännström

I found this post a few steps below mine: Repeating piece of code. Is creating a subclass to CI_Controller and then extend all my controllers from that subclass the best solution? It seems I will still have to make the same method calls even though the method doesn't have to be redefined. Can this be improved even more perhaps?

Theme © iAndrew 2016 - Forum software by © MyBB