Welcome Guest, Not a member yet? Register   Sign In
Need urgent help - Common method for all controller
#2

[eluser]CroNiX[/eluser]
Create a MY_Controller, which is a base controller. This special controller will be called immediately before your normal controllers that extend it. All of your normal controllers that you want the logging enabled would extend MY_Controller instead of CI_Controller.
http://ellislab.com/codeigniter/user-gui...asses.html

/application/core/MY_Controller.php
Code:
class MY_Controller extends CI_Controller {
  pubic function __construct()
  {
    parent::__construct();

    $this->log_uri();
  }

  public function log_uri()
  {
    //your logging code here
  }
}

Then your other controllers that you want to do the automatic logging:

Code:
class Other_controller extends MY_Controller {
  public function index()
  {
    //regular stuff
  }
}

If you don't want something to be logged, then have that controller extend CI_Controller like normal.


Messages In This Thread
Need urgent help - Common method for all controller - by El Forum - 05-04-2014, 11:19 AM
Need urgent help - Common method for all controller - by El Forum - 05-05-2014, 10:21 AM
Need urgent help - Common method for all controller - by El Forum - 05-05-2014, 06:18 PM
Need urgent help - Common method for all controller - by El Forum - 05-05-2014, 10:35 PM
Need urgent help - Common method for all controller - by El Forum - 05-06-2014, 04:20 AM
Need urgent help - Common method for all controller - by El Forum - 05-06-2014, 05:38 AM
Need urgent help - Common method for all controller - by El Forum - 05-06-2014, 06:59 AM
Need urgent help - Common method for all controller - by El Forum - 05-07-2014, 06:11 AM
Need urgent help - Common method for all controller - by El Forum - 05-07-2014, 07:59 AM
Need urgent help - Common method for all controller - by El Forum - 05-07-2014, 08:27 AM
Need urgent help - Common method for all controller - by El Forum - 05-07-2014, 06:04 PM
Need urgent help - Common method for all controller - by El Forum - 05-07-2014, 07:59 PM
Need urgent help - Common method for all controller - by El Forum - 05-08-2014, 04:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB