我已经按照这个答案检查 OpenCart 2.0 中的模块位置,当直接在核心文件中添加代码时,它工作正常。
但是,当通过 Vqmod 添加相同的代码(步骤 3)时(不更改核心文件)。所以,这是行不通的。获取错误(注意:未定义的索引:位置在....)
我们的 Vqmod 代码。
<file path="catalog/controller/common/" name="content_top.php,content_bottom.php,content_right.php,content_left.php">
<operation>
<search position="after">
<![CDATA[$setting_info = $this->model_extension_module->getModule($part[1]);]]>
</search>
<add>
<![CDATA[$setting_info['position'] = basename(__FILE__, '.php');]]>
</add>
</operation>
</file>
我使用的是 OpenCart 版本 2.0.1.1
如何解决?
=== 更新 ===
更改了 vqcache 文件中的代码。
if (isset($part[1])) {
$setting_info = $this->model_extension_module->getModule($part[1]);
if(!isset($setting_info['position'])){
$setting_info['position'] = basename(__FILE__, '.php');
}
if ($setting_info && $setting_info['status']) {
$data['modules'][] = $this->load->controller('module/' . $part[0], $setting_info);
}
当模块在左/右列中启用时。所以,一定要低于错误。
Notice: Undefined index: position in C:\......\template\module\featured.tpl on line 1
当模块在顶部/底部列中启用时。所以,什么都不做显示。