Welcome Guest, Not a member yet? Register   Sign In
Where to place general global variables?
#13

[eluser]Ki[/eluser]
it is VERY easy... I have mentioned this solution to you because I deeply believe it will be the best match for your needs as I had same issue. and there is NO WIKI needed. It is built into CI!

In your system/application/libraries create a file called MY_Controller.php. It will look like this:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class  MY_Controller extends Controller{

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

{you can call db here or define variables, load libraries/models etc}
define('COMPANY_EMAIL','[email protected]'); // you just defined a global variable to use anywhere you want
$this->data['company_email']='[email protected]';

}
function custom(){
{do something else here, if you need another function}
}        
      

}

The above library will allow you to controll everythign you need for ALL of your site in one location. To use it in your controllers simply

Code:
<?php
class Your_controller extends MY_Controller{
    
    function __construct(){
        parent::__construct();
    }

And in all controller you end up extending My_controller, which loads all of CI stuff in Controller + anything you define to load in My_controller


Let me know if you need more help


Messages In This Thread
Where to place general global variables? - by El Forum - 02-20-2010, 05:30 AM
Where to place general global variables? - by El Forum - 02-20-2010, 05:47 AM
Where to place general global variables? - by El Forum - 02-20-2010, 06:13 AM
Where to place general global variables? - by El Forum - 02-20-2010, 06:18 AM
Where to place general global variables? - by El Forum - 02-20-2010, 07:04 AM
Where to place general global variables? - by El Forum - 02-20-2010, 11:17 AM
Where to place general global variables? - by El Forum - 02-20-2010, 12:41 PM
Where to place general global variables? - by El Forum - 02-20-2010, 01:19 PM
Where to place general global variables? - by El Forum - 02-21-2010, 01:28 PM
Where to place general global variables? - by El Forum - 02-21-2010, 01:34 PM
Where to place general global variables? - by El Forum - 02-21-2010, 01:36 PM
Where to place general global variables? - by El Forum - 02-21-2010, 01:46 PM
Where to place general global variables? - by El Forum - 02-21-2010, 01:59 PM
Where to place general global variables? - by El Forum - 02-21-2010, 02:11 PM
Where to place general global variables? - by El Forum - 02-21-2010, 02:19 PM
Where to place general global variables? - by El Forum - 02-22-2010, 02:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB