Welcome Guest, Not a member yet? Register   Sign In
Include Variable
#1

[eluser]yoelrodguez[/eluser]
Hi I have a file with variables that I use throughout the system, as I can include it for use in all controllers
#2

[eluser]Tpojka[/eluser]
You need to extend CI_Controller class. Best approach is to make MY_Controller file located in application/core folder that will extends CI_Controller.
After that you only need to extend your controllers with MY_Controller NOT WITH CI_Controller.
In that file you can store values for approaching later from any file that uses MY_Controller;

application/core/MY_Controller.php
Code:
class MY_Controller extends CI_Controller {

    public $number = 5;    
    public $string    = 'String!';

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
    }
}

application/controllers/blog.php
Code:
class Blog extends MY_Controller {

       public function __construct()
       {
            parent::__construct();
              $string = $this->string;
               $number = $this->number;
       }
}

But also read this page.
#3

[eluser]yoelrodguez[/eluser]
thank you!
#4

[eluser]CroNiX[/eluser]
There is a config system that you can use for this. http://ellislab.com/codeigniter/user-gui...onfig.html

Also, if your file is just a bunch of define() statements or something, you can always just include() it in index.php.




Theme © iAndrew 2016 - Forum software by © MyBB