我遵循了以下步骤,但是仍然出现权限被拒绝的错误.
我正在使用opencart 2.x
1)在admin / controller / custom / helloworld.PHP中创建一个新文件
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'];
}
}
?>
Opencart>管理员>用户>用户组>管理员>编辑
选择并启用访问权限.
解决方法:
>创建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; ?>
>进入系统->用户->用户组->编辑管理员组.选择全部以访问权限,并修改权限并保存.
这是教程http://blog.a2bizz.com/index.php/2015/12/17/create-custom-module-in-opencart-admin/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。