Welcome Guest, Not a member yet? Register   Sign In
how load one controller in to a controller?
#1

[eluser]Unknown[/eluser]
I need load one controller in to a controller for example:

<?php
class Other extends Controller{
var $controller = new One_Controller();

function Other(){
parent::Controller();
}
public function index(){
echo $controller->myfunction();
}
}
?>

how I do???
#2

[eluser]Pascal Kriete[/eluser]
Can you give us some sort of context for doing this. You may just need a library.

It's not possible natively (and I've personally never had the need), however there a few 3rd party libraries that can do this (wick and hmvc come to mind).
#3

[eluser]Bl4cKWid0w[/eluser]
I've found that the easiest way to load header information is to use a model.

Model Example:
Code:
<?php

class constant extends Model {

     function constant(){
          parent::Model();
     }

     function header(){

             //Your information
     }

}

Then just use $this->load->model('constant'); to load the model, and $this->constant->header(); to load the function.
#4

[eluser]Tom Glover[/eluser]
You could try Wick, it's a controller loader, which allows you to load controllers in controllers. Search the forums for it.
#5

[eluser]Developer13[/eluser]
[quote author="Pascal Kriete" date="1230756828"]however there a few 3rd party libraries that can do this (wick and hmvc come to mind).[/quote]

If the OP is truly looking to call one controller function from another controller, then I'd also recommend Wick. I think HMVC would be extreme overkill.
#6

[eluser]Bl4cKWid0w[/eluser]
I really think the best way for him to do this would to use a model. That's what i've been doing. I mean, that's all he needs if he wants to do this:
Quote:public function index(){
echo $controller->myfunction();
}




Theme © iAndrew 2016 - Forum software by © MyBB