小编use*_*342的帖子

opencart 管理自定义页面权限被拒绝

我按照以下步骤操作,但仍然收到权限被拒绝错误。我使用的是opencart 2.x

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

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

你好世界.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());
        }
    }
    ?>
Run Code Online (Sandbox Code Playgroud)

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; ?>
Run Code Online (Sandbox Code Playgroud)

3)在admin/model/custom/hello.php中创建一个新文件

  <?php
    class ModelCustomHello extends Model {
        public function HellWorld() {
            $sql = "SELECT x FROM `" . DB_PREFIX . "y`)"; 
            $implode …
Run Code Online (Sandbox Code Playgroud)

php opencart opencart2.x opencart-module

4
推荐指数
1
解决办法
3705
查看次数

标签 统计

opencart ×1

opencart-module ×1

opencart2.x ×1

php ×1