BlogController.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Admin\Model\BlogModel;
  16. class BlogController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='帮助列表';
  20. $this->breadcrumb2='帮助列表';
  21. $this->blog_type = array('question' => '常见帮助');
  22. //'pinjie' => '拼团介绍',
  23. }
  24. public function index(){
  25. $model=new BlogModel();
  26. $data=$model->show_blog_page();
  27. $this->assign('empty',$data['empty']);// 赋值数据集
  28. $this->assign('list',$data['list']);// 赋值数据集
  29. $this->assign('page',$data['page']);// 赋值分页输出
  30. /**/
  31. $this->display();
  32. }
  33. function add(){
  34. if(IS_POST){
  35. $model=new BlogModel();
  36. $data=I('post.');
  37. $return=$model->add_blog($data);
  38. //echo json_encode($return);
  39. //die();
  40. $this->osc_alert($return);
  41. }
  42. $this->action=U('Blog/add');
  43. $this->crumbs='新增';
  44. $this->display('edit');
  45. }
  46. function edit(){
  47. $model=new BlogModel();
  48. if(IS_POST){
  49. $data=I('post.');
  50. $return=$model->edit_blog($data);
  51. //echo json_encode($return);
  52. //die();
  53. $this->osc_alert($return);
  54. }
  55. $this->crumbs='编辑';
  56. $this->action=U('Blog/edit');
  57. $this->blog_content=M('blog_content')->where(array('blog_id'=>I('id')))->find();
  58. $this->blog=$model->get_blog_data(I('id'));
  59. $this->blog_images=$model->get_blog_image_data(I('id'));
  60. $this->blog_categories=$model->get_blog_category_data(I('id'));
  61. $this->display('edit');
  62. }
  63. function del(){
  64. $model=new BlogModel();
  65. $return=$model->del_blog(I('get.id'));
  66. $this->osc_alert($return);
  67. }
  68. }
  69. ?>