php 管理员 权限问题,php-管理员自定义页面opencart中的权限被拒绝

我遵循了以下步骤,但是仍然出现权限被拒绝的错误.

我正在使用opencart 2.x

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

您的文件名和控制器名称应按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中创建一个新文件

Hello.tpl

HelloWorld

echo 'I can also run PHP too!';

?>

3)在admin / model / custom / hello.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>管理员>用户>用户组>管理员>编辑

选择并启用访问权限.

解决方法:

这是在管理员中添加自定义helloworld模块的方法

>创建admin / controller / custom / helloworld.php

class ControllerCustomHelloworld extends Controller {

public function index() {

$this->load->language('custom/helloworld');

$this->document->setTitle($this->language->get('heading_title'));

$this->load->model('custom/helloworld');

$data['header'] = $this->load->controller('common/header');

$data['column_left'] = $this->load->controller('common/column_left');

$data['footer'] = $this->load->controller('common/footer');

$this->response->setOutput($this->load->view('custom/helloworld.tpl', $data));

}

}

?>

>创建admin / model / custom / helloworld.php

class ModelCustomHelloworld extends Model {

public function helloworldmodel(){

}

}

?>

>创建管理员/语言/英语/自定义/helloworld.php

// Heading

$_['heading_title'] = 'Hello world Admin module';

?>

>创建admin / view / template / custom / helloworld.tpl

<?php echo "This is helloworld admin module in opencart 2.x.x.x "; ?>

>进入系统->用户->用户组->编辑管理员组.选择全部以访问权限,并修改权限并保存.hnEH9.png

标签:opencart,opencart2-x,opencart-module,php

来源: https://codeday.me/bug/20191119/2038892.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值