标签:des style io ar color os sp for strong
1,修改模板页,复制category_list.tpl,category_form.tpl,修改成新的名称。
category_list.tpl是列出页面,category_form.tpl是添加和修改页,删除页和列出页共用模板。
2,控制功能再controller文件夹下
3,model是具体处理数据内容文件夹
4,语言消息页在language文件夹下
删除功能
public function delete() {
$this->language->load(‘catalog/wpcms‘);
$this->document->setTitle($this->language->get(‘heading_title‘));
$this->load->model(‘catalog/wpcms‘);
if (isset($this->request->post[‘selected‘]) && $this->validateDelete()) {
foreach ($this->request->post[‘selected‘] as $category_id) {
$this->model_catalog_wpcms->deletewpcms($category_id); //这里显示调用model中的方法delete
}
$this->session->data[‘success‘] = $this->language->get(‘text_success‘);
$url = ‘‘;
if (isset($this->request->get[‘page‘])) {
$url .= ‘&page=‘ . $this->request->get[‘page‘];
}
$this->redirect($this->url->link(‘catalog/wpcms‘, ‘token=‘ . $this->session->data[‘token‘] . $url, ‘SSL‘));
}
$this->getList(); //这里显示删除完成后调用显示列表
}
来到model文件夹下的具体页面,修改delete方法如下
public function deleteWpcms($Wpcms_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "terms WHERE term_id = ‘" . (int)$Wpcms_id . "‘");
$this->cache->delete(‘Wpcms‘);
}
修改完成后台测试。
添加功能
public function insert() {
$this->language->load(‘catalog/wpcms‘);
$this->document->setTitle($this->language->get(‘heading_title‘));
$this->load->model(‘catalog/wpcms‘);
if (($this->request->server[‘REQUEST_METHOD‘] == ‘POST‘) && $this->validateForm()) {
$this->model_catalog_wpcms->addwpcms($this->request->post);
$this->session->data[‘success‘] = $this->language->get(‘text_success‘);
$url = ‘‘;
if (isset($this->request->get[‘page‘])) {
$url .= ‘&page=‘ . $this->request->get[‘page‘];
}
$this->redirect($this->url->link(‘catalog/wpcms‘, ‘token=‘ . $this->session->data[‘token‘] . $url, ‘SSL‘));
}
$this->getForm();
}
public function addwpcms($data) {
foreach ($data[‘category_description‘] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "terms ( name, slug, term_group) VALUES (‘". $this->db->escape($value[‘name‘]) ."‘, ‘". $this->db->escape($value[‘meta_description‘]) ."‘, 0)");
}
$this->cache->delete(‘wpcms‘);
}
修改功能
public function update() {
$this->language->load(‘catalog/wpcms‘);
$this->document->setTitle($this->language->get(‘heading_title‘));
$this->load->model(‘catalog/wpcms‘);
if (($this->request->server[‘REQUEST_METHOD‘] == ‘POST‘) && $this->validateForm()) {
$this->model_catalog_wpcms->editwpcms($this->request->get[‘category_id‘], $this->request->post);
$this->session->data[‘success‘] = $this->language->get(‘text_success‘);
$url = ‘‘;
if (isset($this->request->get[‘page‘])) {
$url .= ‘&page=‘ . $this->request->get[‘page‘];
}
$this->redirect($this->url->link(‘catalog/wpcms‘, ‘token=‘ . $this->session->data[‘token‘] . $url, ‘SSL‘));
}
$this->getForm();
}
标签:des style io ar color os sp for strong
原文地址:http://www.cnblogs.com/fslnet/p/4117829.html