How to change the method called from class constructor ? |
[eluser]Unknown[/eluser]
Hi ! This is my very first post on here, I'm new to codeigniter ! I found a lor of answers to my newby issues, but one : i call the url customer/first_called , but a switch in the constructor triggers a call to another function constructor_called() instead, and i don't want first_called() to be called anymore. Code: class Customer extends MY_Controller { If I do like this, both functions will be called : constructor_called() then first_called() How can i prevent first_called() to be called? Thanks for any tip, cheers ! Nicolas (France)
[eluser]wh1tel1te[/eluser]
Hi ndavoust, I don't think it is possible to do this sort of thing in CI (calling methods from the constructor without triggering the currently called method). Try the following code, then call the URL customer/ Code: class Customer extends MY_Controller {
[eluser]WanWizard[/eluser]
To catch the called method and do custom routing within the controller, use the _remap() method. See the user guide: http://ellislab.com/codeigniter/user-gui...#remapping (it is an excellent read, and a must before you start with CI!)
[eluser]Unknown[/eluser]
Thanks WanWizard ! This was exactly what I needed and it works like a charm ! Great to start the day by learning something new and see my project go one step ahead ! :-) |
Welcome Guest, Not a member yet? Register Sign In |