title: Extending custom config array in Codeigniter within a view file
body: <p>I'am using a codeigniter 2.x. What i need is to insert a values into an array of <code>config/template.php</code> from inside of a view file <code>/views/home.php</code>.</p>
  
  <p>I've created a custom config file <code>application/config/template.php</code>:</p>
  
  <pre><code>$config['site_name'] = "Sitename";
  $config['site_lang'] = "En-en";
  $config['page_name'] = "Pagename";
  $config['css_page'] = "default";
  $config['alias'] = "";
  
  $config['head_meta'] = array(
      'description' =&gt; 'description',
      'keywords' =&gt; 'meta, keywords',
      'stylesheets' =&gt; array(
          'template.css'
      ),
      'scripts' =&gt; array(
          'jquery.js',
          'template.js'
      ),
      'charset' =&gt; 'UTF-8'
  );
  $config['sidebars'] = array();
  </code></pre>
  
  <p>Then, i use <code>application/views/template/template.php</code> as my main HTML layout, where at the beginning I include a file <code>application/views/template/includes/inc-tpl-cfg.php</code> which globalize my configurations for a template into an one file with arrays, so i could access them a little bit easier. Here is the content of that <code>inc-tpl-cfg.php</code>:</p>
  
  <pre><code>&lt;?php
  
  // No direct acces to this file
  if (!defined('BASEPATH')) exit('No direct script access allowed');
  
  /* Template configuration needs to be defined to make them accessible in the whole template */
  $cfg_template = array(
      'sitename'      =&gt; $this-&gt;config-&gt;item('site_name'),
      'sitelang'      =&gt; $this-&gt;config-&gt;item('site_lang'),
      'pagename'      =&gt; $this-&gt;config-&gt;item('page_name'),
      'csspage'       =&gt; $this-&gt;config-&gt;item('css_page'),
      'charset'       =&gt; $this-&gt;config-&gt;item('charset','head_meta'),
      'description'   =&gt; $this-&gt;config-&gt;item('description','head_meta'),
      'keywords'      =&gt; $this-&gt;config-&gt;item('keywords','head_meta'),
      'stylesheets'   =&gt; $this-&gt;config-&gt;item('stylesheets','head_meta'),
      'scripts'       =&gt; $this-&gt;config-&gt;item('scripts','head_meta'),
      'sidebars'      =&gt; $this-&gt;config-&gt;item('sidebars')
  );
  
  /* Template variables */
  $cfg_assetsUrl = base_url() . 'assets';
  
  // If pagename exists than concatenate it with a sitename, else output only sitename
  if(!empty($cfg_template['pagename'])){
      $title = $cfg_template['pagename'] . ' - ' . $cfg_template['sitename'];
  }else{
      $title = $cfg_template['sitename'];
  }
  </code></pre>
  
  <p>And one part in my main template layout is block with sidebars:</p>
  
  <pre><code>&lt;div id="tpl-sidebar"&gt;
    &lt;?php foreach($cfg_template['sidebars'] as $sidebar):?&gt;
      &lt;?php $this-&gt;load-&gt;view('modules/'. $sidebar);?&gt;
    &lt;?php endforeach ;?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And at last, it loads a <code>application/views/home.php</code> into the specific <code>div</code> block inside <code>applications/views/template/template.php</code>. This is a <code>/views/home.php</code>:</p>
  
  <pre><code>&lt;?php
  
  // No direct acces to this file
  if (!defined('BASEPATH')) exit('No direct script access allowed');
  
  // Page configuration
  $this-&gt;config-&gt;set_item('page_name','Homepage');
  $this-&gt;config-&gt;set_item('css_page','home');
  $this-&gt;config-&gt;set_item('alias','home');
  
  ?&gt;
  
      &lt;p&gt;
          WELCOME BLABLABLA
      &lt;/p&gt;
  &lt;/h3&gt;
  </code></pre>
  
  <p>There is a section where i can define/overwrite a default values from <code>config/template.php</code> and use a specific ones for each views. So my questions is, how can i extend a <code>$config[sidebar]</code> array inside this view file by inserting some new items, for exemple: <code>recent.php</code>,<code>rss.php</code> etc... ?</p>
  
  <p>Sorry for a big code.</p>
  
  <p>Thanks in advance.</p>