2

Is there a simple way of calling a module (in this case module/html) inside a div of the TPL, in WordPress we could use shortcodes to do that, is there any way to do something like that in OpenCart without having to create a new layout position using only the module id for example?

focus.style
  • 6,612
  • 4
  • 26
  • 38
Rui Leming
  • 61
  • 10

1 Answers1

2

Open controller file of your tpl. For example in catalog/controller/common/header.php

Find (should be row 3)

public function index($setting) {

Add after

$this->load->model('extension/module');
$module_id = 5;  // your html module ID
$custom_html = $this->model_extension_module->getModule($module_id);

if ($custom_html && $custom_html['status']) {
  $data['module_html'] = $this->load->controller('extension/module/html', $custom_html);
}else{
  $data['module_html'] = '';
}  

Than in header.tpl add

<?php echo $module_html; ?>
focus.style
  • 6,612
  • 4
  • 26
  • 38