Welcome Guest, Not a member yet? Register   Sign In
how to call to a Controller from another Controller
#1

[eluser]chinedubond[/eluser]
Hi there,
am new CI and i am very impressed with it.
i would like to know how to call a controller from another Controller?
All my previous attempts have been throwing errors
e.g
new SomeController; gives unknown class
so how do u call a controller from another Controller? in other to use its functions.
Thank you
#2

[eluser]gtech[/eluser]
Hello,

have a search on the forums as this is a very common question.

[url="http://ellislab.com/forums/viewthread/79614/"]http://ellislab.com/forums/viewthread/79614/[/url]
#3

[eluser]Pascal Kriete[/eluser]
First off welcome to CodeIgniter.

The easiest answer I can give you - is don't. By design, controllers are kept separate. Libraries, helpers, and plugins are made specifically for shared content. So if you have functionality that is needed by more than one controller. Put it in a library.
#4

[eluser]gtech[/eluser]
inheritance is another method you can use. So you create a base controller with common content and then your other controllers can extend the base controller.

There are examples in the link I gave you. But inparo is correct in saying you don't really call a controller from a controller.




Theme © iAndrew 2016 - Forum software by © MyBB