I have a config table like:
CREATE TABLE `wfbp_config` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`type` VARCHAR(20) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
`slug` VARCHAR(20) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
`title` VARCHAR(50) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
`description` VARCHAR(120) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
`value` VARCHAR(120) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
`values` VARCHAR(120) NOT NULL DEFAULT '0' COLLATE 'utf8_unicode_ci',
PRIMARY KEY (`id`),
UNIQUE INDEX `slug` (`slug`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB;
I store config values at this table but...
I need to change value's field_type by type's column value, like:
if ($type=='image')
$this->crud->set_field_upload('value', $this->config->item('upload_path'));
elseif ($type=='text')
$this->crud->field_type('value','text');
elseif ($type=='date')
$this->crud->field_type('value','date');
elseif ($type=='dropdown')
$this->crud->field_type('value','date', explode(',', $values));
/* etc... */
But i have to change this after rendering the crud. And it's impossible (i guess). And i cannot achieve this with callbacks!
Is there any way to solve this with this table structure or is there any suggestion for a new table structure (but not all config values in one row).
For now i'm using multiple crud pages with unique config. like: sitename/panel/config-string/tr/system/ or sitename/panel/config-images/tr/system/ etc... i want to merge this values.
Thanks in advance.
P.S. I try to get config values like this:
Model:
function get_config($config_slug) {
$this->db->where('slug', $config_slug)
->where('lang', LANG_STR);
$qr = $this->db->get('config');
if ($qr->num_rows() == 1) {
return $qr->row()->config_value;
} else {
return false;
}
}
Helper:
function config($config_slug) {
$wf=& get_instance();
$wf->load->model('site_model');
return $wf->site_model->get_config($config_slug);
}
Thanks again...
