您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在opencart中创建自定义管理页面?

如何在opencart中创建自定义管理页面?

路径名称在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

您的文件名和控制器名称应按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

<?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**

其他 2022/1/1 18:20:29 有733人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶