有没有一种简单的方法可以在 TPL 的 div 中调用模块(在本例中为 module/html),在 WordPress 中我们可以使用短代码来做到这一点,有什么方法可以做到吗?类似于 OpenCart 中的内容,而无需仅使用模块 id 创建新的布局位置?
最佳答案
打开 tpl 的 Controller 文件。例如在catalog/controller/common/header.php
查找(应为第 3 行)
public function index($setting) {
添加到之后
$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'] = '';
}
比在header.tpl中添加
<?php echo $module_html; ?>
关于php - Opencart:在 .TPL 中添加 module/html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62892066/