Welcome Guest, Not a member yet? Register   Sign In
Call controller from another (code organization)

i have this problem.
I have 2 controllers: home and offers.
I need to call in many functions of the home controller, a function of the offers controller.

How can I do this?
Do I have to extend the home class?
Do I have to include the offers controller file?

Tried many ways without success...

Question 2:
Is correct to call from home class the offers class or would be better to create a library?
Or something like that?


It is not correct to call functions from another controller. Think of controllers as the final "layer" of abstraction before the user. The controller is the interface the user sees, and is unique for the specific action the user wishes to perform. Any code that is shared between classes should be stored in models or libraries.

In this case it sounds like you want to have the code in models, home_model and offers_model respectively.

Theme © iAndrew 2016 - Forum software by © MyBB