Welcome Guest, Not a member yet? Register   Sign In
Call a private controller method from within another controller
#2

[eluser]CroNiX[/eluser]
A few choices.
1) HVMC. This will let you create modules (mini applications) which can be called from multiple controllers, but might be overkill if you just need it for something small.
2) Library. Create a library class that is doing what you need. Then call the library from the controllers that need it.
Code:
class New_class
{
    public CI;

    public function __construct()
    {
        parent::__construct();
        $this->CI =& get_instance();
    }

    public function something()
    {
        $this->CI->load->model('some_model');
        return $this->CI->some_model->get_data();
    }
}

...in some controller...

Code:
$this->load->library('new_class');
$class_data = $this->new_class->something();
...in some other controller...
Code:
$this->load->library('new_class');
$class_data = $this->new_class->something();


Messages In This Thread
Call a private controller method from within another controller - by El Forum - 01-16-2011, 12:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB