Extension of Config Class

#1
[eluser]Unknown[/eluser]
When using the Config class you can
Code:
// Stored in an array with this prototype: $this->config['blog_settings'] = $config
$this->config->load('blog_settings', TRUE);

But you can not dynamically add items to this specific index. I'm using this to build my site menu.
So I added this to the Config class

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

Class MY_Config extends CI_Config
{
    function MY_Config()
    {
        parent::CI_Config();
    }
    
    /**
     * Set a config file item
     *
     * @access    public
     * @param    string    the config item key
     * @param    string    the config item value
     * @param   string  an optional section to save the item
     * @return    void
     */
    function set_item($item, $value, $section="")
    {
         if( $section === "" )
         {
            $this->config[$item] = $value;    
        }
        else
        {
            $this->config[$section][$item] = $value;
        }
    }
    
    // --------------------------------------------------------------------

}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.