OpenCart 2.x
路径名称在OpenCart 2中已更改-您将要创建
admin/controller/extension/module/hello.php admin/language/en-gb/extension/module/hello.php admin/view/template/extension/module/hello.tpl
然后路线变成
admin/index.php?route=extension/module/hello
OpenCart 1.x
- 包括完整的MVC流。
我发现了如何做到这一点。OpenCart使用MVC模式。我建议阅读有关如何成为OpenCart
Guru的内容?有关了解系统工作原理的文章-此Admin工作流也应足以满足客户需求。
1)在中创建一个新文件
admin/controller/custom/helloworld.php
您的文件名和控制器名称应按desc顺序相同:
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
<?php echo $header; ?><div id="content"><h1>HelloWorld</h1><?phpecho 'I can also run PHP too!'; ?></div> <?php echo $footer; ?>
3)在中创建一个新文件
admin/model/custom/hello.php
<?phpclass 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**



