Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] My_Controller ?
#10

[eluser]CroNiX[/eluser]
/application/core/MY_Controller.php
Code:
class MY_Controller extends CI_Controller {
  function __construct()
  {
    parent::__construct();
  }

  //this will be available in all of your controllers now
  function universal_method()
  {
    return 'hello';
  }
}

now one of your controllers (extends MY_Controller)
/application/controllers/something.php
Code:
class Something extends MY_Controller {
  function __construct()
  {
    parent::__construct();
  }

  function show_message()
  {
    //access the method we defined in MY_Controller
    $data['message'] = $this->universal_message(); //now is 'hello'
    $this->load->view('some_view', $data);
  }
}

View
/application/views/some_view.php
Code:
<?php echo "Message is: $message"; ?>

access via url:
http://yoursite.com/something/show_message


Messages In This Thread
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 05:56 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 06:02 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 06:06 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 07:02 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 07:18 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 07:36 PM
[SOLVED] My_Controller ? - by El Forum - 09-14-2012, 10:58 PM
[SOLVED] My_Controller ? - by El Forum - 09-15-2012, 11:55 AM
[SOLVED] My_Controller ? - by El Forum - 09-15-2012, 11:57 AM
[SOLVED] My_Controller ? - by El Forum - 09-15-2012, 12:03 PM
[SOLVED] My_Controller ? - by El Forum - 09-15-2012, 04:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB