如何在opencart中创建自定义管理页面?
我想知道如何在opencart中创建自定义管理面板页面。
需要使用控制器登录-
管理面板似乎没有使用与普通站点相同的控制器。我知道如何使用opencart制作自定义页面(但这不适用于管理员)
一个简单的Hello World示例将是很棒的
回答:
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顺序相同:
<?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
<?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**
以上是 如何在opencart中创建自定义管理页面? 的全部内容, 来源链接: utcz.com/qa/420666.html





