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

[eluser]omed habib[/eluser]
I have a function, addanewclient, within a controller as such:
Code:
class Home extends Controller {

    function Home()
    {
        parent::Controller();    
    
    }
    
    
    function addanewclient() {            
            $this->load->view('homepage');        
    }
}
My question is this: I have another controller called 'Clients' and within it I have a function that is IDENTICAL to the 'addanewclient' from the 'Home' controller. Is there a way to call 'addanewclient' from Home while I am stll within the 'Clients' controller?
For example:
Code:
class Clients extends Controller {

    function Clients()
    {
        parent::Controller();    
    
    }
    
    
    function addanewclient() {            
        // some kind of code goes here that
        // calls the other function within the other controller        
    }
}
Thanks!!
#2

[eluser]gtech[/eluser]
I would recommend searching the forums as this topic has come up many times Smile. Personally Id create a library, Or reorganize my controllers so I don't have to make calls across them. Other people have different methods.
#3

[eluser]gtech[/eluser]
Ah here you go...

[url="http://ellislab.com/forums/viewthread/55212/"](controller within a controller thread)[/url]




Theme © iAndrew 2016 - Forum software by © MyBB