the code in form and insert function :
Code: Select all
public function insert(){
$this -> load -> language('news/news');
$this -> load -> model('news/news');
// Warning code skipped
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_news_news->addNews($this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect($this->url->link('module/news', 'token=' . $this->session->data['token'], 'SSL'));
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('module/news', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['action'] = $this->url->link('module/news/insert', '&token=' . $this->session->data['token'], 'SSL');
$this->data['cancel'] = $this->url->link('module/news', '&token=' . $this->session->data['token'], 'SSL');
$this->data['token'] = $this->session->data['token'];
$this->form();
}
private function form() {
$this -> load -> language('news/news');
$this -> load -> model('news/news');
$this -> load -> model('localisation/language');
// Language code skipped
$this->data['languages'] = $this->model_localisation_language->getLanguages();
if (isset($this->request->get['news_id'])) {
$news = $this->model_news_news->getNews($this->request->get['news_id']);
} else {
$news = '';
}
if (isset($this->request->post['news'])) {
$this->data['news'] = $this->request->post['news'];
} elseif (!empty($news)) {
$this->data['news'] = $this->model_news_news->getNewsDescription($this->request->get['news_id']);
} else {
$this->data['news'] = '';
}
if (isset($this->request->post['keyword'])) {
$this->data['keyword'] = $this->request->post['keyword'];
} elseif (!empty($news)) {
$this->data['keyword'] = $news['keyword'];
} else {
$this->data['keyword'] = '';
}
if (isset($this->request->post['status'])) {
$this->data['status'] = $this->request->post['status'];
} elseif (!empty($news)) {
$this->data['status'] = $news['status'];
} else {
$this->data['status'] = '';
}
$this->template = 'news/news_form.tpl';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}

