Welcome Guest, Not a member yet? Register   Sign In
call one controller to another controller
#1

I want to call to one controller function to another function,it gives error

First controller name is status

second controller name is Users

 $this->load->library('../controllers/Users');

          $this->Users->index();
Reply
#2

1) You cannot load controllers that way
2) You are not meant to "call" one controller from another

If you have functionality in controller A that you wish to use in controller B, then have B extend A, so that the function is then part of B.
Reply
#3

You mix up controllers and libraries.
A library is a class with methods (functions) you can use in any controller where you load that library.

A controller always extends the CI_Controller class (or MY_Controller). That's why CI recognizes it as a controller.
The methods inside a controller are triggered by the url that you are using, or from within the controller itself.

Libraries must be located in the libraries folder.
The methods of the library are available after loading the library (in your controller).
More info: https://www.codeigniter.com/userguide3/g...aries.html
Reply
#4

@kvanaraj,

It also might do you some good to do the CI tutorial ( https://codeigniter.com/user_guide/tutorial/index.html ).
Reply
#5

I think you need HMVC.

https://bitbucket.org/wiredesignz/codeig...downloads/

Quote:Modular Extensions makes the CodeIgniter PHP framework modular. Modules are groups of independent components, typically model, controller and view, arranged in an application modules sub-directory that can be dropped into other CodeIgniter applications.

HMVC stands for Hierarchical Model View Controller.

Module Controllers can be used as normal Controllers or HMVC Controllers and they can be used as widgets to help you build view partials.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB