首页  >  文章  >  后端开发  >  codeigniter小弟我的删除不知道是不能传参还是路由有关问题

codeigniter小弟我的删除不知道是不能传参还是路由有关问题

WBOY
WBOY原创
2016-06-13 11:52:50800浏览

codeigniter我的删除不知道是不能传参还是路由问题

路由是这样的
PHP复制代码
$route['default_controller'] = 'pages/view';
 
$route['content/(:any)'] = 'content/view/$1';
$route['content'] = 'content';
$route['content/del/(:any)'] = 'content/del/$1';
$route['content/add'] = 'content/add';
$route['(:any)'] = 'pages/view/$1';
 
$route['404_override'] = '';
复制代码




控制器是这样的
PHP复制代码
 
        public function __construct()
        {
                parent::__construct();
                $this->load->model('content_model');
        }
        
        public function index()
        {
                $data['title'] = 'Content archive';
                $data['content'] = $this->content_model->get_content();
                
                $this->load->view('templates/header', $data);
                $this->load->view('content/index', $data);
                $this->load->view('templates/footer');
        }
        
        public function view($slug)
        {
                $data['content_item'] = $this->content_model->get_content($slug);
                
                if (empty($data['content_item']))
                {
                        show_404();
                }
                
                $data['title'] = $data['content_item']['title'];
                
                $this->load->view('templates/header', $data);
                $this->load->view('content/view', $data);
                $this->load->view('templates/footer');
        }
        
        public function add()
        {
                $this->load->helper('form');
                $this->load->library('form_validation');
                  
                $data['title'] = 'Add a content item';
                  
                $this->form_validation->set_rules('title', 'Title', 'required');
                $this->form_validation->set_rules('text', 'text', 'required');
                  
                if ($this->form_validation->run() === FALSE)
                {
                        $this->load->view('templates/header', $data);  
                        $this->load->view('content/add');

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn