Best way to order class functions(poor title) |
[eluser]Kola[/eluser]
Hey, I've been slightly confused as how I should do this. Basicly I have a controller called admin.php, this controller is checking if a user is logged in or not, and it controls which views are being shown. So if I'm at http://root/index.php/admin/page/news/ it will load: $this->load->view('news'); however, when I load the news page it loads an overview which I need a method for, so I thought: I'll just make a news.php controller and make a function display_news(){} with the appropiate method within that. However, these normally end up gathering data and passing it to a view, so in the end of display_news() it would say something like $this->load->view('news', $data); Is my base structure wrong? as in is there a more sensible way to order these things. Or should I maybe create the news file as a helper (or maybe an overall admin_helper for various admin tasks) which I can load and then call display_news() in the view file? Hope anyone got a few cents on this. regards
[eluser]toopay[/eluser]
Authentification, is a regular function which you may perform at most of your controller. Thats the main reason, why you need a separated "library" to handle that stuff, or create two "type" of your controller, which can be a global parent for the rest of your controller. In CI spec, the "softer" way to do that, is creating MY_Controller and specify those two (or more) types of controller, like... Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
Welcome Guest, Not a member yet? Register Sign In |