Welcome Guest, Not a member yet? Register   Sign In
controller extends controller, same for models
#1

[eluser]UnknownPlayer[/eluser]
Hi,
can controller extend another controller ?

Example:
Code:
class Social extends User {

function __construct() {
  parent::__construct();
}
}

where user is controller .

And same question for models ?
#2

[eluser]Aken[/eluser]
Yes, but CI does not include any autoloading functionality, so you'll need to include/require the file or set up your own autoloader.
#3

[eluser]UnknownPlayer[/eluser]
You mean MY_Controller ?
I have that, but i don't wanna include User controller in every page.
#4

[eluser]boltsabre[/eluser]
This might help you:
http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY

Else if just wanted a handful of your controllers to extend the user controller, all you have do is include your "user" controller file in the controller/s you want to extend user like this:
Code:
<?php
include_once('path/to/user.php');
lass Social extends User {
   //constructor

}
You can't use functions/code/classes in a file without first including the file!
#5

[eluser]UnknownPlayer[/eluser]
Thanks, this is what i need.




Theme © iAndrew 2016 - Forum software by © MyBB