如何在opencart中创建自定义管理页面? [英] How to create a custom admin page in opencart?

查看:200
本文介绍了如何在opencart中创建自定义管理页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在opencart中创建自定义管理面板页面.

I want to know how to make a custom admin panel page in opencart.

需要使用控制器登录-管理面板似乎未使用与普通站点相同的控制器.我知道如何使用opencart制作自定义页面(但这不是给管理员的)

Requires login with the controller - the admin panel does not seem to use the same controller as the normal site. I know how to make custom pages with opencart (but this is not for the admin)

一个简单的Hello World示例将很棒

A simple Hello World example would be great

推荐答案

OpenCart 2.x

OpenCart 2中的路径名已更改-您将要创建

OpenCart 2.x

The path names have changed in OpenCart 2 - you will want to create

admin/controller/extension/module/hello.php admin/language/en-gb/extension/module/hello.php admin/view/template/extension/module/hello.tpl 然后路由变为

admin/controller/extension/module/hello.php admin/language/en-gb/extension/module/hello.php admin/view/template/extension/module/hello.tpl Then the route becomes

admin/index.php?route=extension/module/hello

  • 包括完整的MVC流.

我发现了该怎么做. OpenCart使用MVC模式.我建议阅读有关如何成为OpenCart大师?有关如何学习系统可以正常工作-此Admin工作流程也应足以满足客户需求.

I found out how to do this. OpenCart uses the MVC pattern. I recommend reading about How to be an OpenCart Guru? post about learning how the system works - this Admin workflow should also suffice for customer end.

1)在admin/controller/custom/helloworld.php

您的文件名和控制器名称应按desc顺序相同:

Your filename and controller name should be the same in desc order:

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)在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)然后,您需要启用插件,以避免权限被拒绝的错误:

4) You then need to enable the plugin to avoid permission denied errors:

Opencart > Admin > Users > User Groups > Admin > Edit

选择并启用访问权限.

要访问您的页面,请访问

To visit your page go to

www.yoursite.com/opencart/admin/index.php?route=custom/helloworld

这篇关于如何在opencart中创建自定义管理页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆