Reputation: 192
I want to add code in all controller file of module in admin side using OCMOD.
My code is:
<file path="admin/controller/module/*.php">
<operation>
<search trim="true"><![CDATA[
public function index() {
]]></search>
<add position="after" trim="true"><![CDATA[
$this->document->addScript('catalog/view/javascript/xxxx.js');
]]></add>
</operation> </file>
But it doesn't work.
Upvotes: 1
Views: 778
Reputation: 4221
I have try your code. It is working fine. please try following.
You have to create ocmod xml file with ".ocmod.xml" extension, then you can upload that file using "Extension Installer" from admin panel of opencart.
You have to clear and refresh the modification cache to update the system and make the extension work. You can clear and refresh by top right buttons on Extension > Modification page in admin panel.
Example OCMOD file with your code: (File name: test.ocmod.xml)
<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>mycode001</code>
<name>Modification Default</name>
<version>1.0</version>
<author>OpenCart</author>
<link>http://www.opencart.com</link>
<file path="admin/controller/module/*.php">
<operation>
<search trim="true">
<![CDATA[public function index() {]]>
</search>
<add position="after" trim="true">
<![CDATA[$this->document->addScript('catalog/view/javascript/xxxx.js');]]>
</add>
</operation>
</file>
</modification>
Upvotes: 1