So my tables are like this ;
CREATE TABLE IF NOT EXISTS `item_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category_name` varchar(256) NOT NULL,
`category_seo` varchar(256) NOT NULL,
`category_alt` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
CREATE TABLE IF NOT EXISTS `item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`item_name` varchar(256) NOT NULL,
`item_desc` text NOT NULL,
`item_image` varchar(256) NOT NULL,
`item_category` int(5) NOT NULL,
`item_seo` varchar(256) NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
category_alt is parent category id.
My product list function is ;
public function product_list()
{
$crud = new grocery_CRUD();
$crud->set_table('item');
$crud->columns('item_name','item_image','item_category','item_seo','item_desc');
$crud->display_as('item_name','Ürün Adı');
$crud->display_as('item_image','Ürün Resmi');
$crud->display_as('item_category','Ürün Kategorisi');
$crud->display_as('item_seo','Düzenli URL');
$crud->display_as('item_desc','Ürün Açıklama');
$crud->fields('item_name','item_image','item_category','item_seo','item_desc');
$crud->set_relation('item_category','item_category','{category_name}-');
$crud->add_fields('item_name','item_image','item_category','item_seo','item_desc');
$crud->change_field_type('item_seo', 'invisible');
$crud->change_field_type('item_image', 'invisible');
$crud->callback_before_insert(array($this,'seo_urun'));
$crud->callback_before_update(array($this,'seo_urun'));
$crud->add_action('Resim Düzenle', base_url().'assets/grocery_crud/themes/flexigrid/css/images/add.png', '','ui-icon-image',array($this,'resim_link'));
$output = $crud->render();
$data['css']=str_replace(base_url()."assets/","", $output->css_files);
array_push($data['css'],'admin.css');
$data['js']=str_replace(base_url()."assets/","", $output->js_files);
$data['output']=$output->output;
$data['icerik']="theme/admin/urun_ekle";
$this->load->view('theme/index', $data);
}
i need to show parent category name in below code because i have similar category names
$crud->set_relation('item_category','item_category','{category_name}-');
like this,
$crud->set_relation('item_category','item_category','{category_name}- CALLBACKFORPARENTCATEGORYNAME(category_alt)');
I hope i can explain my problem.
Thank you.