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.

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.... )


Our Vqmod Code.

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

I am used OpenCart Version 2.0.1.1

How to fix it?


=== Update ===

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.

Community
  • 1
  • 1
HDP
  • 4,005
  • 2
  • 36
  • 58
  • The actual errors seems to not be related with the xml vqmod script part you provided, did you update accordingly the featured.php and featured.tpl? The error seems to be related to the values not being passed, for example if you do not follow the modifications " $data['module'] = $setting; " in featured.php – Jonid Bendo Jan 07 '15 at 09:39
  • I have already add it. I think, issue not in it. because, when I have add this `$setting_info['position'] = basename(__FILE__, '.php');` Direct in file. So, it is working fine. but, it is add via vqmod. So, It is not work. – HDP Jan 08 '15 at 05:41
  • I am sorry for the delayed answer but i was away. If you are sure that the everything else is fine this means only one thing (the only possible reason), that the modified file is not well modified or the original file is called nonetheless. Reading some more i see that opencart 2.0 and up use OCMod and VQMod is not compatible with them for the moment. Link to article: http://forum.opencart.com/viewtopic.php?f=34&t=129261 – Jonid Bendo Jan 22 '15 at 09:31

1 Answers1

0

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.

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.

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');]]>

with:

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

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.

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

Jonid Bendo
  • 860
  • 2
  • 10
  • 16
  • I have try. but, this is not work. & also, I have check vqcache folder. So, there rendered code is perfect. – HDP Jan 06 '15 at 07:13
  • I made the code a bit cleaner. Can you please post the part of the changed code from vqcache on one of these files, and the complete error shown on screen? – Jonid Bendo Jan 06 '15 at 07:54