Search code examples
opencart-3ocmod

Newbie OCMOD question - does using 'add' make changes on EVERY instance of the search string or just one?


This is going to be a really basic question and yes, I HAVE looked at the documentation. If this question is answered there, my apologies for not seeing the answer. When using add to modify code, does it perform its magic on every matching string in a file or just the first one it finds?

Example: The OpenCart 3.0.2.0 file admin/controller/customer/customer.php contains 13 lines that load the language file ('$this->load->language('customer/customer');') If I use the following XML in my install.xml file, how many times will the code to load my language file get inserted into admin/controller/customer/customer.php? Thanks in advance!

<operation>
    <search><![CDATA[$this->load->language('customer/customer');]]></search>
    <add position="after"><![CDATA[
        $this->load->language('extension/my_custom_extension/checkout');
        ]]></add>
</operation>

Solution

  • If you have in file several lines $this->load->language('customer/customer'); the code will be added after each this line in the file. if you need add only somewhere just only after the first line of the code, you should use index. For example: <add position="after" index="0"> now it will be added after the first line.