简体   繁体   English

Opencart:在.TPL 中添加模块/html

[英]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?有没有一种简单的方法可以在 TPL 的 div 中调用模块(在本例中为module/html ),在 WordPress 中,我们可以使用简码来做到这一点,有没有办法在 OpenCart 中执行类似的操作而无需创建例如,仅使用模块 ID 的新布局 position?

Open controller file of your tpl.打开您的 tpl 的 controller 文件。 For example in catalog/controller/common/header.php例如在目录/controller/common/header.php

Find (should be row 3)查找(应该是第 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比在header.tpl添加

<?php echo $module_html; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM