更新
>包括完整的MVC流。
我发现如何做到这一点。 OpenCart使用MVC模式。我建议阅读关于学习如何系统工作的How to be an OpenCart Guru?帖子 – 这个管理员工作流程也应该足够客户端。
1)在admin / controller / custom / helloworld.php中创建一个新文件
您的文件名和控制器名称应按照降序排列:
helloworld.php
class ControllerCustomHelloWorld extends Controller{
public function index(){
// VARS
$template="custom/hello.tpl"; // .tpl location and file
$this->load->model('custom/hello');
$this->template = ''.$template.'';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}
}
?>
2)在admin / view / template / custom / hello.tpl中创建一个新文件
Hello.tpl
HelloWorld
echo 'I can also run PHP too!';
?>
3)在admin / model / custom / hello.php中创建一个新文件
class ModelCustomHello extends Model {
public function HellWorld() {
$sql = "SELECT x FROM `" . DB_PREFIX . "y`)";
$implode = array();
$query = $this->db->query($sql);
return $query->row['total'];
}
}
?>
4)然后需要启用插件,以避免权限被拒绝错误:
Opencart > Admin > Users > User Groups > Admin > Edit
选择并启用访问权限。
要访问您的网页,请转到
www.yoursite.com/opencart/admin/index.php?route=custom/helloworld