• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call a controller function from another controller

Hi there,

Just wondering if it is possible to call a controller function from another controller.. so for example say I have Controller 1 that has a function called function 1 and then I have controller 2. I want to be able to access function1 of controller 1 from controller 2. Is that possible? the reason I want to do this is because I have a generic function that I want a few controllers to use.


[eluser]GSV Sleeper Service[/eluser]
In theory you call them like this - Controller1::function() - I haven't tried this in codeigniter though.
A generic function should really be in a library, or maybe a helper.

For the readers, try this solution: http://ellislab.com/forums/viewreply/748866/

This is a perfect example of why you should have thin controllers and fat models.

Models are NOT just for storing database libraries. It is perfectly acceptable to store website logic in models.

So, when you need some specific data in more than one controller, just load the model for it and pass the data to the view. Done.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.