Tuesday, April 8, 2014

Installing, configuring, and uninstalling a module [Getting Started with OpenCart Modules]

There are many default modules in OpenCart. How modules get installed and which are the database tables that hold the settings of the module are really big questions for the developer.
Installing a module
Navigate to admin | Extensions | Modules, where you will find the list of modules. Click on [Install] and the module gets installed, as shown in the following screenshot:


When you click on the [Install] module, the extension/module controller's install function is called. Now open admin/controller/extension/module.php, you will see the public function install(),which performs the permission check. If you get the Permission Denied! message, as shown in the following screenshot, you have to provide the access permission from admin | User | User Group and edit the user and check or tick mark the module/extension, so you will be able to edit the modules.


If you are provided the access, it loads the admin/model/setting/extension.php function install().
public function install($type, $code) {
  $this->db->query("INSERT INTO " . DB_PREFIX ."extension SET `type`
= '" . $this->db->escape($type) . "', `code` = '" . $this->db-
>escape($code) . "'");
}
This means that data is inserted into the extension table of the database with type=module, and code=helloworld, in case of our Hello World module.

No comments:

Post a Comment