Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Several types of custom controller #1287

Closed
dazld opened this Issue · 2 comments

3 participants

@dazld

I've noticed what seems to be a major weakness in CI's handling of controllers.

The functionality provided by being able to extend the native controller is excellent, but I don't understand why we can't have several types of extended controllers. I absolutely do not want to be handling stuff like front end calls through a page router, or mixing admin logic in display controllers.

Is there a way to be able to have things like

class Cart extends MY_Cart {
    // etc
}

class Pages extends MY_Pages {
    // etc 
}

class Admin extends MY_Admin {
    // and so on
}

Any ideas?

@philsturgeon

It's been possible for a while now, I wrote an article for 1.7.1 back in 2010 that shows you how:

http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-base-Classes-Keeping-it-DRY

Trouble is working out a decent autoloading system that will handle this and everything else at the same time. How far does autoloading go, and what should the limitations be?

@narfbg
Owner
MY_Controller.php:
<?php
class MY_Controller {}
class Cart_Controller {}
class Pages_Controller {}
class Admin_Controller {}

... extend as you wish.

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.