【问题标题】:Permission Denied in admin custom page opencart管理员自定义页面opencart中的权限被拒绝
【发布时间】:2015-09-01 08:29:03
【问题描述】:

我遵循了以下程序,但我仍然收到权限被拒绝错误。 我正在使用 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 > 管理员 > 用户 > 用户组 > 管理员 > 编辑 选择并启用访问权限。

【问题讨论】:

    标签: php opencart opencart2.x opencart-module


    【解决方案1】:

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

    1. 创建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));
      
       }
      }
      ?>
      
    2. 创建admin/model/custom/helloworld.php

      <?php
      class ModelCustomHelloworld extends Model {
      
      public function helloworldmodel(){
      
       }
      }
      ?>
      
    3. 创建admin/language/english/custom/helloworld.php

      <?php
      // Heading
      $_['heading_title']          = 'Hello world Admin module';
      
      ?>
      
    4. 创建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; ?>
      
    5. 转到system -&gt; users -&gt; user groups -&gt; edit Administrator group。全选access permissionmodify permission并保存。

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

    【讨论】:

      【解决方案2】:

      我建议您查看以下 URL 以获取解决方案-

      Step by step process to create a custom Admin page in Opencart

      Fixing the permission error

      希望以上链接对你有所帮助。

      【讨论】:

      • 我检查了用户组中的所有访问权限。仍然显示错误。你能把所有代码发给我一次吗?
      猜你喜欢
      • 2018-06-17
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      • 2021-04-26
      相关资源
      最近更新 更多