Rui Leming
Rui Leming

Reputation: 61

Opencart: add module/html inside .TPL

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?

Upvotes: 2

Views: 381

Answers (1)

focus.style
focus.style

Reputation: 6760

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; ?>

Upvotes: 2

Related Questions