Kaimonokago create and update


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. class Admin extends Shop_Admin_Controller {
  2.  
  3. private $module;
  4.  
  5. function Admin(){
  6. parent::Shop_Admin_Controller();
  7. // Check for access permission
  8. check('Menus');
  9. // define this module which will be used later
  10. $this->module=basename(dirname(dirname(__FILE__)));
  11. // Set breadcrumb
  12. $this->bep_site->set_crumb($this->lang->line('backendpro_menus'),$this->module.'/admin');
  13. }
  14.  
  15.  
  16. function _fields(){
  17. $data = array(
  18. 'name' => db_clean($_POST['name']),
  19. 'shortdesc' => db_clean($_POST['shortdesc']),
  20. 'status' => db_clean($_POST['status'],8),
  21. 'parentid' => id_clean($_POST['parentid']),
  22. 'order' => id_clean($_POST['order'],10),
  23. 'page_uri_id' => db_clean($_POST['page_uri_id']),
  24. 'lang_id' => db_clean($_POST['lang_id']),
  25. 'menu_id' => db_clean($_POST['menu_id'])
  26. );
  27. // $this->MKaimonokago->addItem($this->module, $data);
  28. return $data;
  29. }
  30.  
  31.  
  32.  
  33. function create(){
  34.  
  35. if ($this->input->post('name')){
  36.  
  37. $data = $this-> _fields();
  38. $this->MKaimonokago->addItem($this->module, $data);
  39.  
  40. flashMsg('success',$this->lang->line('kago_created'));
  41. redirect($this->module.'/admin/index','refresh');
  42. }else{
  43.  
  44. }
  45. }
  46.  
  47. function edit($id=0){
  48.  
  49. if ($this->input->post('name')){
  50. $data = $this-> _fields();
  51. $this->MKaimonokago->updateItem($this->module,$data);
  52.  
  53. $this->session->set_flashdata('message','Menu updated');
  54. flashMsg('success',$this->lang->line('kago_updated'));
  55. redirect($this->module.'/admin/index','refresh');
  56. }else{
  57.  
  58.  
  59. }
  60. }
  61.  
  62. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.