0

My first mod in VQmod for OpenCart 2 is working, but the code is being inserted in the wrong place. I am probably missing something simple but its confusing me greatly. The code should insert inside a <td>, after the current content & before the closing </td>. But instead the code is appearing outside the </td>

Here is the mod : Please note the SEARCH finishes with the closing ?> php tag (& before the closing </td> in the original code)

<?xml version="1.0" encoding="UTF-8"?>
<modification>
   <id>customize orders page</id>
   <version>1.0</version>
   <vqmver>2.X</vqmver>
   <author>PaulR</author>
   <file name="admin/view/template/sale/order_list.tpl">
       <operation info="add the card/delivery country text">
           <search position="after"><![CDATA[<td class="text-left"><?php echo $order['customer']; ?>]]></search>
           <add><![CDATA[<?php
           $tf_style1=($order['payment_country']==$order['shipping_country']?"font-size: x-small;":"font-size: x-small; color: red;");
            echo "<br /><span style=\"".$tf_style1."\">".$order['payment_country']." / ".$order['shipping_country']."</span>";
            ?>]]></add>
       </operation>
   </file>
</modification>

The result in the browser is as follows : you can see my content is appearing AFTER the </td>

<td class="text-left">Paul R</td>
<br /><span style="font-size: x-small; color: red;">United Kingdom / United States</span> 

Here is the code snippet from the original file:

<td class="text-right"><?php echo $order['order_id']; ?></td>
<td class="text-left"><?php echo $order['customer']; ?></td>
<td class="text-left"><?php echo $order['status']; ?></td>
Paul R
  • 1
  • 1
    It seems I had a fundamental misunderstanding on how VQmod works. It will not insert my code at the end of the SEARCH match, it will match the entire line. So, I can modify the above to do a replace of the whole line, including the original code plus my new code. – Paul R May 26 '15 at 03:45
  • hmm, i did not have a fundamental misunderstanding after all - you can insert code at the end of the search string, but *specifically* in the above case it doesn't work for some reason. – Paul R May 26 '15 at 04:54

1 Answers1

0

My modification should aim to replace the entire LINE of code.

        <?xml version="1.0" encoding="UTF-8"?>
        <modification>
           <id>customize orders page</id>
           <version>1.0</version>
           <vqmver>2.X</vqmver>
           <author>PaulR</author>
           <file name="admin/view/template/sale/order_list.tpl">
               <operation info="add the card/delivery country text">
                   <search position="replace"><![CDATA[<td class="text-left"><?php echo $order['customer']; ?></td>]]></search>
                   <add><![CDATA[

<td class="text-left"><?php echo $order['customer']; 
    $tf_style1=($order['payment_country']==$order['shipping_country']?"font-size: x-small;":"font-size: x-small; color: red;");
    echo "<br /><span style=\"".$tf_style1."\">".$order['payment_country']." / ".$order['shipping_country']."</span>";
                    ?></td>
    ]]></add>
               </operation>
           </file>
        </modification>
Paul R
  • 1
  • Although my fix to replace the entire line will work, it is not actually the correct answer to my question. I AM able to insert code after a search mid-way through a line - but just not in the case shown in the original question - so i am still confused about that...? – Paul R May 26 '15 at 04:52
  • Perhaps your `$order['customer']` contains a closing `td` tag? You should rather concatenate if you are going to replace. **Use a single echo** eg. `$tf_style =...` then `echo $order['customer'] . "br />` etc . – Sarfaraaz Jun 15 '15 at 11:07
  • @Sarfaraaz Thanks for the comment, but i did a test on a bare bones file containing this: `

    One two three four five

    ` _after_ will not insert inside those `

    ` tags - eg; if i try to insert after the word THREE it will still appear after the closing P tag - either its a bug in VQ, or its intended (cant see why) or its something with VQ on my machine causing this unexpected behaviour.

    – Paul R Jun 17 '15 at 00:22
  • strange. I have vqmod v2.5.1. I get the `

    One two three four five 6

    ` **not** `

    One two three four five

    6`
    – Sarfaraaz Jun 17 '15 at 09:08