What Are OpenCart Modules?
OpenCart modules are analogous to add-ons, plugins, or extensions in other content management systems. It's through modules that OpenCart gives us the ability to extend its functionality without having to edit the application's files.
As with many other content management systems, it's generally considered to be a best practice to extend functionality of the core application through the provided APIs and OpenCart is no different. Modules allow us to introduce, remove, or modify functionality of the core application that's done in a compartmentalized and maintainable way.
To take things a step further, we're going to look at creating a custom module for OpenCart.
Our First Module
To get started, perform the following:
1. Create an Controller to Admin
2. Create a Language File to Admin
3. Create a View to Admin Path: .
1. The Language File
As discussed in our previous articles, the language file
contains the static text what should be displayed in our view file. For
file, the following variables contain the possible text fields what we require
to display in our module:
1. The Controller
As we tried to validate data on save in default function. So here comes the validation method.
3. View File
As previously done in controller, you have to create some HTML for the view. For that, we'll do the following:
Step 4: At this point, we're done preparing our first popular module. At this point, it's time to check whether our module is working or not.
To do that, login to dashboard and go to the Extensions Tab->Extensions page where you'll see option Choose the extension type and select modules from the dropdown.
There will also be "popular" listed with an "Uninstalled" State, click on "Install" and try editing the module and you'll see a screen something like this:
In this article, we tried to build a basic OpenCart Module using MVC. It's easy to manipulate OpenCart Modules if you're familiar with the core concepts of MVC. This article gives just a basic idea how to develop a simple module following some simple steps.