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

[eluser]Unknown[/eluser]
Bear with me because I'm new to the MVC style of doing things...

I know I can use _remap() in a controller to call a different method than the default send in the second segment. But can I call a method from another controller?

I have two controllers, one called "Signup" and one called "Dashboard." Signup contains all the logic for creating a new member, and Dashboard contains all the tools the user has on the site. There are a couple Dashboard pages I'd like to be part of the signup process.

I want /signup/configure to call Dashboard->configure() rather than Signup->configure(). I couldn't quite figure out from the documentation if I can do that with _remap. Or can I create the configure method in Signup and just call Dashboard->configure() from it?
#2

[eluser]jedd[/eluser]
Hi kellbot, and welcome to the CI forums.

There are ways and means, but you may be better served by moving the common method(s) into a [url="http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html"]library function[/url] instead.

Alternatively, redesign things such that each controller contains a coherent set of logically related components.




Theme © iAndrew 2016 - Forum software by © MyBB