我想知道如何在opencart中创建自定义管理面板页面。如何在opencart中创建自定义管理页面?
需要使用控制器登录 - 管理面板似乎没有使用与正常站点相同的控制器。我知道how to make custom pages with opencart(但这不是为admin)
一个简单的Hello World例子将是巨大的
我想知道如何在opencart中创建自定义管理面板页面。如何在opencart中创建自定义管理页面?
需要使用控制器登录 - 管理面板似乎没有使用与正常站点相同的控制器。我知道how to make custom pages with opencart(但这不是为admin)
一个简单的Hello World例子将是巨大的
名称在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模式。我建议您阅读关于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
<?php echo $header; ?>
<div id="content">
<h1>HelloWorld</h1>
<?php
echo 'I can also run PHP too!';
?>
</div>
<?php echo $footer; ?>
3)创建
<?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
好,repped - 大啧啧。我认为这不是必须的,尽管'$ this-> load-> model('catalog/information');'可能会减慢代码加载不需要的库,特别是在拥有多个管理员用户的繁忙网站上。 – AlphaApp
@AlphaApp谢谢。对于评论和喜欢。 – TheBlackBenzKid
admin/view/custom/hello.tpl应该由admin/view/template/custom/hello.tpl –