Welcome Guest, Not a member yet? Register   Sign In
How can i make my own config file?
#1

[eluser]developer10[/eluser]
i want to have a file to store my config items. what is the best way of doing this and how am i supposed to retrieve config items from it?

i tried something like this, but it didn't work (NOTE: i looked into some app and tried to replicate this):

i created a file named "app_config" and saved it in the config folder of my application.

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

$config['some_item'] = 'blah-blah-blah';

?>

then in my file "Functions" which is located in library folder, put this:

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

class Functions
{
    
    function Functions()
    {
        $this->ci =& get_instance();
        
        $this->ci->load->config('app_config');
    }
}

in my controller, i load this library
Code:
$this->load->library('functions');

Now, i try to retrieve "some_item" value from config (with or without "echo"):

Code:
$this->app_config->some_item;
Code:
$this->functions->some_item;

EDIT: neither of those ways works.


is this the correct way or i'm doing something wrong? do i really need to import config file into library file before i'm
able to use it, or there's a better solution?

Thanks!
#2

[eluser]flaky[/eluser]
this is how you retrieve config values
Code:
$var = $this->config->item('some_item');
#3

[eluser]Phil Sturgeon[/eluser]
http://ellislab.com/codeigniter/user-gui...onfig.html
#4

[eluser]developer10[/eluser]
[quote author="Phil Sturgeon" date="1262188546"]http://ellislab.com/codeigniter/user-gui...onfig.html[/quote]

thanks, i didnt know this existed in user guide




Theme © iAndrew 2016 - Forum software by © MyBB