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



 <?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>管理员>用户>用户组>管理员>编辑
选择并启用访问权限.

解决方法:

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

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

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

<?php
class ModelCustomHelloworld extends Model {

public function helloworldmodel(){

 }
}
?>

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

<?php
// Heading
$_['heading_title']          = 'Hello world Admin module';

?>

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

<?php echo $header; ?><?php echo $column_left; ?>
<h1><?php echo "This is helloworld admin module in opencart 2.x.x.x "; ?></h1>         
<?php echo $footer; ?>

>进入系统->用户->用户组->编辑管理员组.选择全部以访问权限,并修改权限并保存.php-管理员自定义页面opencart中的权限被拒绝

这是教程http://blog.a2bizz.com/index.php/2015/12/17/create-custom-module-in-opencart-admin/

上一篇:php-为OpenCart创建开发环境


下一篇:使用pyvis对社交网路数据可视化