Welcome Guest, Not a member yet? Register   Sign In
is it possible to extend an application controller?
#6

[eluser]louis w[/eluser]
Of course you can. This is an overview of how I have my CMS structured. Multiple levels of extending to keep everything organized.


Code:
// FILE:  controllers/application.php
class Application extends Controller {

    // Contains global application methods. Never called directly

}


// FILE: controllers/admin/admin.php
require_once(APPPATH . 'controllers/application.php');
class Admin extends Application {
    
    // Contains admin only admin global methods.

}


// FILE: controllers/admin/pages.php
require_once(APPPATH . 'controllers/admin/admin.php');
class Pages extends Admin {
    
    // Page admin controller

}


// FILE: controllers/site.php
require_once(APPPATH . 'controllers/application.php');
class Site extends Application {
    
    // Website controller    

}

This could also be cleaned up further by setting php up to autoload the classes. I prefer to include it explicitly.

I have multiple controllers which extend Admin, which all inherit both application and admin methods. Makes adding additional sections very easy.


Messages In This Thread
is it possible to extend an application controller? - by El Forum - 05-19-2009, 01:36 AM
is it possible to extend an application controller? - by El Forum - 05-19-2009, 01:44 AM
is it possible to extend an application controller? - by El Forum - 05-19-2009, 02:06 AM
is it possible to extend an application controller? - by El Forum - 05-19-2009, 03:44 AM
is it possible to extend an application controller? - by El Forum - 05-19-2009, 03:54 AM
is it possible to extend an application controller? - by El Forum - 05-19-2009, 09:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB