I have a file app/config/template.php
:
$config['head_meta'] = array(
'charset' => 'UTF-8',
'description' => '',
'keywords' => '',
'stylesheets' => array(
'template.css'
),
'scripts' => array(
'plugins/jquery-2.0.3.min.js',
'plugins/bootstrap.min.js'
),
'end_scripts' => array(
'template.js'
)
);
I need to override that description inside my controller's function app/controllers/pages.php
:
function contact($pagename = 'Contact', $slug = 'contact'){
// load dependencies
$this->load->library('form_validation');
$this->lang->load($slug);
// page settings
$this->config->set_item('page_name', $this->lang->line('menu_subtitle_contact'));
$this->config->set_item('page_slug', $slug);
$description = $this->config->item('description', 'head_meta');
var_dump($description);
$data['view'] = $this->load->view($slug, '', TRUE);
$this->load->view('templates/default', $data);
}
How I suppose to do that ? In CI2's docs, there is an example to override config's value like this: $this->config->set_item('configItem', 'value');
But how it should be if my config's item is an array ? I tried $this->config->set_item('description', 'head_meta', 'NewValue');
but it didn't work
Thanks for advices
Unfortunately, by using
$this->config->set_item('item_name', 'item_value');
, it isn't possible to change a specific array item inside the config value.You probably have to get the current config value, modify it and set it again: