Php 管理员自定义页面opencart中的权限被拒绝
我遵循了下面的过程,但仍然遇到了权限被拒绝的错误。 我正在使用opencart 2.x 1) 在admin/controller/custom/helloworld.php中创建一个新文件Php 管理员自定义页面opencart中的权限被拒绝,php,opencart,opencart2.x,opencart-module,Php,Opencart,Opencart2.x,Opencart Module,我遵循了下面的过程,但仍然遇到了权限被拒绝的错误。 我正在使用opencart 2.x 1) 在admin/controller/custom/helloworld.php中创建一个新文件 <? class ControllerCustomHelloWorld extends Controller{ public function index(){ // VARS $template
<?
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());
}
}
?>
文件名和控制器名称的描述顺序应相同:
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; ?>
Hello.tpl
你好世界
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>管理员>用户>用户组>管理员>编辑
选择并启用访问权限。我建议您查看以下URL以获得解决方案-
我希望以上链接能对您有所帮助。以下是在管理中添加自定义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));
}
}
?>
<?php
class ModelCustomHelloworld extends Model {
public function helloworldmodel(){
}
}
?>
<?php
// Heading
$_['heading_title'] = 'Hello world Admin module';
?>
admin/language/english/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));
}
}
?>
<?php
class ModelCustomHelloworld extends Model {
public function helloworldmodel(){
}
}
?>
<?php
// Heading
$_['heading_title'] = 'Hello world Admin module';
?>
系统->用户->用户组->编辑管理员组
。选择全部以访问权限
和修改权限
并保存这是教程我检查了用户组中的所有访问权限。仍然是显示错误。你能一次把所有代码发给我吗。