not sure how to do this... i have an controller name admin- and i want to use the controllers in a subfolder as "sub" controllers
i.e when a user visits mydomain.com/admin they are redirected if they are not logged and if they visit mydomain.com/admin/customers they are also redirected but the actual customers class is stored in controllers/admin/customers.php
i want the admin controller to handle the check if logged in and add on the header template?
how can i route this?开发者_StackOverflow
If I understand you correctly, try extending the base controllers
<?php
class MY_Controller extends Controller
{
function __construct()
{
parent::__construct();
if(!$this->auth->logged_in())
{
redirect('login');
}
}
}
class Customer extends MY_Controller {
// if the user isn't logged in they will be redirected
}
I cite once again Phil Sturgeon
精彩评论