3

I want to load a controller function from another controller function using codeigniter. What is the suitable way to do this so when call it url should be changed also.

3
  • Check this. Commented Oct 5, 2015 at 8:04
  • You can not do that with standard codeigniter you need a third party add on called HMVC. bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc Commented Oct 5, 2015 at 8:12
  • basically this is not how MVC functions if you want to call one controller to another then your code requires refactoring Commented Oct 5, 2015 at 9:06

2 Answers 2

3

No You cant do it.

What you have to do it is create that function in model and call it through your controllers. So it will work fine.

Ex

In Model

function get_id()
{
   //some argument 
}

In controller 1

$this->Model_name->get_id()

In controller 2

$this->Model_name->get_id()
Sign up to request clarification or add additional context in comments.

Comments

0

yes you can (for version 2)

load like this below inside your controller

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

and call the following method:

$this->whathever->functioname();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.