If I want to load controller or module on every page , Should I load controller every time? My question is what is the best practice to load controller on every page?
Asked
Active
Viewed 59 times
1 Answers
1
If You need to load a model inside of another model, You could load it the very same way using $this->load->model('my_module/my_model');
.
If You need to load a model inside of template file or other custom PHP script, look at the index.php file where the Registry is instantiated - You would need to instantiate it the same way. So Your custom code could look like:
$registry = new Registry();
$my_model = $registry->load->model('my_module/my_model');
$my_model->customFunction();
In this way you can do it.

Hardik Patel
- 706
- 5
- 14
-
Sorry I'm new in opencart. For example If I want to load the footer I have to load the footer controller $this->load->controller('common/header'); inside one controller (Ex: home). But If I inside another another controller (Ex: Information) I have to load footer controller again. What should I do? – Chhorn Soro Feb 03 '15 at 07:16
-
you can load as $this->load->controller('common/header'); as you want in any controller. – Hardik Patel Feb 03 '15 at 07:19
-
But I have to load it on every controller , If I want to show it all page.Is it right – Chhorn Soro Feb 03 '15 at 07:21