gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 01:10:11 27 4
gpt4 key购买 nike

我想知道如何在 opencart 中制作自定义管理面板页面。

需要使用 Controller 登录 - 管理面板似乎没有使用与普通站点相同的 Controller 。我知道how to make custom pages with opencart (但这不适用于管理员)

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

最佳答案

OpenCart 2.x

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

admin/controller/extension/module/hello.php
admin/language/en-gb/extension/module/hello.php
管理/查看/模板/扩展/模块/hello.tpl
那么路线就变成了

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

OpenCart 1.x

  • 包括完整的 MVC 流程。

我找到了如何做到这一点。 OpenCart 使用 MVC 模式。我建议阅读 How to be an OpenCart Guru?发布有关了解系统工作原理的帖子 - 此管理工作流程也应该足以满足客户端的需求。

1) 在admin/controller/custom/helloworld.php中新建一个文件

您的文件名和 Controller 名称在 desc 顺序上应该相同:

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中新建文件

你好.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

关于php - 如何在 opencart 中创建自定义管理页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10700761/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com