通过vqmod添加代码时出错 [英] Get error when Code add via vqmod

查看:98
本文介绍了通过vqmod添加代码时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循此答案在OpenCart 2.0中检查模块位置并且可以正常工作,直接在核心文件中添加代码即可.

I have follow this answer Check module position in OpenCart 2.0 and it is working fine When add it code direct in core file.

但是,这时,相同的代码(第3步)通过Vqmod(无需更改核心文件)添加.因此,这是行不通的.得到错误(注意:未定义的索引:在...中的位置)

But, when, this same code (Step 3) add via Vqmod (without change core file). So, It is not work. Get error ( Notice: Undefined index: position in.... )


我们的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版

I am used OpenCart Version 2.0.1.1

如何解决?


===更新===

更改了vqcache文件中的代码.

changed code in vqcache file.

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);
            }

在左/右"列中启用模块时.因此,请避免出现以下错误.

When module Enabled in Left/right column. So, do get below error.

Notice: Undefined index: position in C:\......\template\module\featured.tpl on line 1

在顶部/底部列中启用模块时.因此,什么也不显示.

When module Enabled in Top/bottom column. So, do nothing display.

推荐答案

好吧,我已经有一段时间没有关注OpenCart了,但是我想我可以回想起类似的情况,因此我可以为您解决问题.

Well i have not been following OpenCart for a while now but i think i can help you with your question as i seem to recall a similar situation.

首先,我建议您始终检查 vqcache 文件夹中所输出的代码,以便您有更全面的了解.

First of all i suggest you always check the vqcache folder for the code that is outputted so you can have a more thorough look.

第二个问题似乎是,通过vqmod添加它会首先触发对变量的检查,即实际上该变量实际上不是事先初始化的,但此时已初始化,因此会出现未定义索引"错误.该解决方案应该更换:

Secondly the issue seems to be that adding it via vqmod triggers the check for the variable first that it is actually not initialized beforehand but at that moment and thus you get an " Undefined index" error. the solution should be replacing:

<![CDATA[$setting_info['position'] = basename(__FILE__, '.php');]]>

具有:

    <![CDATA[
                if(!isset($setting_info['position'])){
                    $setting_info['position'] = basename(__FILE__, '.php');
                }
    ]]>

通常的想法是检查变量是否存在,然后才应手动解决.如果没有,则应该在vqcache文件夹中调试生成的文件,并查看实际呈现的代码是什么.

The general idea is a check for the variable if it exists before hand should be the solution. If not you should debug the generated file in your vqcache folder and see what is the actual rendered code.

希望我能为您提供更多帮助,但是我已经很长时间没有使用OpenCart了(特别是新版本).

I wish I could help you more, but I haven't used OpenCart for a long time (especially the new versions).

这篇关于通过vqmod添加代码时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆