Suppose we have a controller named pages_controller.php, in which there is a function named index().
Now we are working in an another controller named users_controller.php, and we want to use the index function defined in Pages Controller.
App::import('Controller', 'Pages'); class UsersController extends AppController { var $Pages; function beforeFilter() { $this->Pages =& new PagesController; /*Loads the class*/ $this->Pages->constructClasses(); /*Loads the model associations, components, etc. of the Pages controller*/ } function index() { $this->Pages->index(); } }
Thanks!! it works perfectly!