To explore the code of defualt featured module, let’s start with listing what files are used by the Featured module:
Admin folder files:
- admin\controller\extension\module\featured.php
Explained at https://webocreation.com/exploring-the-code-of-default-featured-module/ - admin\language\en-gb\extension\module\featured.php
Explained at https://webocreation.com/exploring-the-code-of-default-featured-module/ - admin\view\template\extension\module\featured.tpl
Explained at https://webocreation.com/opencart-module-development-video-tutorial-introduction-and-table-of-contents/
Catalog folder files:
- catalog\controller\extension\module\featured.php
Explained at https://webocreation.com/catalog-controller-code-description-featured-module-front-end-opencart - catalog\language\en-gb\extension\module\featured.php
Explained at https://webocreation.com/opencart-module-development-video-tutorial-introduction-and-table-of-contents/ - catalog\view\theme\default\template\extension\module\featured.tpl
Explained at https://webocreation.com/opencart-module-development-video-tutorial-introduction-and-table-of-contents/
How to know which files are used by module?
Always look to the URL. For Featured module, go to Admin >> Extensions >> Extensions >> Choose “Modules” from the dropdown. Then find the “Featured” and then click the blue Add button (if the module is already installed nor you have to install the module and click the blue button). You will see URL like below:
http://localhost/opencart2302/admin/index.php?route=extension/module/featured&token=LMEWZBoKMxfr1D7s2dhYe5niRfOAz0Ak
See the value of route, here route=extension/module/featured, as this is in admin so your token value may be different.
While seeing for the files always start from the route, the route gives you the controller file and inside the controller, we can find the language file, model file, and template file.
Now as per the route value go to admin folder >> controller folder >> extension folder >> module folder >> and find featured.php file.
In this way, you can find the controller file, controller file end with .php extension. From controller file you can find the language file used by that controller with lines of code as
$this->load->language('extension/module/featured');
It means that admin >> language >> LANGUAGE folder >> extension folder >> module folder >> featured.php
Like that you can find the language file, language file ends with .php extension.
To find the view file find code that start with $this->response->setOutput. In the featured module it is like below:
$this->response->setOutput($this->load->view('extension/module/featured', $data));
It means that admin >> view >> extension folder >> module folder >> featured.tpl
Like this way you can find the view file, view files end with .tpl extension.