예제 #1
0
 function article_create()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('title', 'Titel', 'required|callback_article_unique_title');
     $this->form_validation->set_rules('intro', 'Einführungstext', 'required');
     $this->form_validation->set_rules('category[]', 'Kategorie', 'required');
     $this->form_validation->set_rules('body', 'Text', 'required');
     if ($this->form_validation->run() == TRUE) {
         $articlecategories = new Articlecategory();
         $articlecategories->where_in('id', $this->input->post('category'))->get();
         $article = new Article();
         $article->title = $this->input->post('title');
         $article->alias = $this->_title_to_alias($article->title);
         $article->intro = $this->input->post('intro');
         $article->body = $this->input->post('body');
         $article->state = 1;
         $article->save($articlecategories->all);
         redirect('artikel');
     } else {
         $articlecategories = new Articlecategory();
         $this->template->set('res_articlecategories', $articlecategories->get());
         $this->template->set_block('sidebar', 'content/articles/_sidebar_create');
         $this->template->set('page_name', 'Artikel schreiben');
         $this->template->current_view = 'content/articles/create';
         $this->template->render();
     }
 }