Reputation: 107
I followed Below procedure But still i m getting permission denied error . I am using opencart 2.x
1) Create a new file in admin/controller/custom/helloworld.php
Your filename and controller name should be the same in desc order:
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) Create a new file in 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) Create a new file in 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) You then need to enable the plugin to avoid permission denied errors:
Opencart > Admin > Users > User Groups > Admin > Edit Select and Enable the Access Permission.
Upvotes: 4
Views: 3750
Reputation: 760
Here is the way add custom helloworld module in admin
create 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));
}
}
?>
Create admin/model/custom/helloworld.php
<?php
class ModelCustomHelloworld extends Model {
public function helloworldmodel(){
}
}
?>
create admin/language/english/custom/helloworld.php
<?php
// Heading
$_['heading_title'] = 'Hello world Admin module';
?>
Create 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; ?>
Go to system -> users -> user groups -> edit Administrator group
. Select all to access permission
and modify permission
and save.
Here is the tutorial http://blog.a2bizz.com/index.php/2015/12/17/create-custom-module-in-opencart-admin/
Upvotes: 5
Reputation: 616
I would suggest you to have a look into following URLs for the resolution-
Step by step process to create a custom Admin page in Opencart
I hope above links will help you.
Upvotes: 0