路径名称在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使用MVC模式。我建议阅读有关如何成为OpenCart Guru的内容?有关了解系统工作原理的文章-此Admin工作流也应足以满足客户需求。
1)在中创建一个新文件 admin/controller/custom/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
<?PHP echo $header; ?>
<div id="content">
<h1>HelloWorld</h1>
<?PHP
echo 'I can also run PHP too!';
?>
</div>
<?PHP echo $footer; ?>
3)在中创建一个新文件 admin/model/custom/hello.PHP
<?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'];
}
}
?>
Opencart > Admin > Users > User Groups > Admin > Edit
选择并启用访问权限。
要访问您的页面,请访问
**www.yoursite.com/opencart/admin/index.PHP?route=custom/helloworld**