Common methods for all controllers |
[eluser]owidiuszek[/eluser]
Hello, What is the best way to make few methods available to all controllers? for example some result view: Code: function showResult($text, $state) $this->showResult('aaa','bbb'); (or similar) without pasting this code inside each controller. Should I create for example maincontroller and then extend all others basing on it? Or maybe usage of library or helper would be better?
[eluser]umefarooq[/eluser]
if your loading view for your result you can use widget plugin for your problem have look on the link http://ellislab.com/forums/viewthread/109584/
[eluser]mattpointblank[/eluser]
This is what libraries and helpers are for. If it's just a small function then a helper seems best to me.
[eluser]davidbehler[/eluser]
Quote:Should I create for example maincontroller and then extend all others basing on it? That's exactly what I would do. No need for a helper/library here.
[eluser]Boris Strahija[/eluser]
You could use MY_Controller http://ellislab.com/codeigniter/user-gui...asses.html
[eluser]owidiuszek[/eluser]
MY_Controller works nicely and smoothly. But if it is the same idea as making own controller and extending others on it - what is the point of making it as a library? Anyway Thanks |
Welcome Guest, Not a member yet? Register Sign In |