I am trying to add a variable in language file using opencart extension, but there is no change in the file.
My code:
<file path="admin/language/english/catalog/product.php">
<operation>
<search><![CDATA[// Error]]></search>
<add position="before"><![CDATA[
$_['entry_a_start_date'] = 'Start Date/Time';
]]>
</add>
</operation>
</file>`
Please let me know what is wrong with the code.
Thanks in advance
When you want to call a single file use name not path.
This should work:
<file name="admin/language/english/catalog/product.php">
<operation>
<search position="before"><![CDATA[// Error]]></search>
<add><![CDATA[
$_['entry_a_start_date'] = 'Start Date/Time';
]]>
</add>
</operation>
</file>
Related
Why does this opencart 2 OCMod not work?
<modification>
<file name="catalog/language/english/english.php">
<operation>
<search><![CDATA[
$_['text_home'] = '<i class="fa fa-home"></i>';
]]></search>
<add position="replace"><![CDATA[
$_['text_home'] = 'Home';
]]></add>
</operation>
</file>
</modification>
I upload it and refresh the mods cache, but my changes do not appear.
Add Search Tag "<search position="replace">"
<modification>
<file name="catalog/language/english/english.php">
<operation>
<search position="replace"><![CDATA[
$_['text_home'] = '<i class="fa fa-home"></i>';
]]></search>
<add position="replace"><![CDATA[
$_['text_home'] = 'Home';
]]></add>
</operation>
</file>
Try this,
<modification>
<name><![CDATA[<font color="#0000"><b>Home link</font>]]></name>
<version><![CDATA[<b>1.0</b>]]></version>
<code>home_link</code>
<author><![CDATA[<font color="#CC0000"><b>zec Blackbeard</b></font>]]></author>
<link><![CDATA[abcd.com]]></link>
<file path="catalog/language/english/english.php">
<operation>
<search><![CDATA[$_['text_home'] = '<i class="fa fa-home"></i>';]]></search>
<add position="replace"><![CDATA[$_['text_home'] = 'Home';]]></add>
</operation>
</file>
</modification>
You have mode sily mistake. In ocmod, file name attribute does not work. You need to replace with path.
You need to change following line.
Find
<file name="catalog/language/english/english.php">
Replace with
<file path="catalog/language/english/english.php">
I am trying to get value of special $date_start and $date_end on product page. I'm using opencart version 2.0x. please help manually thank you.
For Special price date
create you own ocmod file for ex. special_price.ocmod.xml, Paste the following code and install from extension installer
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name><![CDATA[<font color="#0000"><b>Special Price</font>]]></name>
<version><![CDATA[<b>1.0</b>]]></version>
<code>specialprice_dates</code>
<author><![CDATA[<font color="#CC0000"><b>A2bizz Blogs</b></font>]]></author>
<link><![CDATA[http://blogs.a2bizz.com]]></link>
<file path="catalog/controller/product/product.php">
<operation error="skip">
<search><![CDATA[ $data['discounts'] = array(); ]]></search>
<add position="before" ><![CDATA[
if($data['special']){
$special_info = $this->model_catalog_product->getSpecialPriceInfo($this->request->get['product_id']);
}else{
$special_info = '';
}
]]></add>
</operation>
<operation error="skip">
<search><![CDATA[ 'special' => $special, ]]></search>
<add position="after" ><![CDATA[
'special_info' => $special_info,
]]></add>
</operation>
</file>
<file path="catalog/model/catalog/product.php">
<operation error="skip">
<search><![CDATA[ public function getLatestProducts($limit) { ]]></search>
<add position="before" ><![CDATA[
public function getSpecialPriceInfo($product_id){
$sql = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "product_special WHERE product_id = '".$product_id."'");
return $sql->row;
}
]]></add>
</operation>
</file>
</modification>
Add following code in product.tpl
<?php if ($product['special_info']) { ?>
<p><?php echo "<pre>"; print_r($product['special_info']); exit;?></p>
<?php } ?>
Here you can get the special price information.
I am using Opencart 1.5.6.4
I am able to set Permissions to All other pages but I am not getting option to set permission to set permission for dashborad or common/home.
I am trying follow link http://forum.opencart.com/viewtopic.php?t=32561
But I am not able to get options to set permission.
I found the answer. To HIDE Dashboard from certain users following are the steps we need to take.
Open admin\controller\user\user_permission.php
FIND
$ignore = array('common/home',
'common/startup',
'common/login',
'common/logout',
'common/forgotten',
'common/reset',
'error/not_found',
'error/permission',
'common/footer',
'common/header'
);
REMOVE
'common/home',
Create XML file and add under vqmod xml folder.
<modification>
<id>Add a permission check to the admin dashboard, and provide with an alternate forwarding target</id>
<version>1.0.0</version>
<vqmver>1.0.2</vqmver>
<author>ckonig</author>
<file name="admin/controller/user/user_permission.php">
<operation>
<search position="replace">
<![CDATA['common/home',]]>
</search>
<add>
<![CDATA[]]>
</add>
</operation>
</file>
<file name="admin/view/template/common/home.tpl">
<operation>
<search position="after">
<![CDATA[<?php echo $header; ?>]]>
</search>
<add>
<![CDATA[
<?php
if(!$this->user->hasPermission('access','common/home')){
$this->redirect('index.php?token='.$token.'&route=catalog/product');
}
?>
]]>
</add>
</operation>
</file>
</modification>
NEXT SET Permission
I am trying to create Sub menu under Product menu using VQMOD, but unfortunately i couldn't able to display it in admin. Please see below for the code i used to create menu using VQMOD.
<modification>
<id>Add a link</id>
<version>1.5.4</version>
<vqmver>0.1</vqmver>
<author>Nagamani Naresh</author>
<!-- edit header controller -->
<file name="admin/controller/common/header.php">
<!-- create link to your page -->
<operation error="log">
<search position="after"><![CDATA[$this->data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
<add><![CDATA[
$this->data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
<!-- / -->
</file>
<!-- edit header template -->
<file name="admin/view/template/common/header.tpl">
<!-- add link to your page -->
<operation error="log">
<search position="before" offset="1"><![CDATA[<ul class="right">]]></search>
<add><![CDATA[
<li><a class="top">Your link</a>
<ul>
<li>Hello World</li>
</ul>
</li>
]]></add>
</operation>
<!-- / -->
</file>
</modification>
Please share your Suggestions.
for opencart 2.0.X
save this code as name.ocmod.xml and uplaod from admin
<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>extra admin menu</code>
<name>test admin menu</name>
<version>2.0</version>
<author>codertj</author>
<link>codertj.com</link>
<!-- edit header controller -->
<file name="admin/controller/common/menu.php">
<!-- create link to your page -->
<operation error="log">
<search><![CDATA[$data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
<add position="after"><![CDATA[
$data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
</file>
<!-- edit header template -->
<file name="admin/view/template/common/menu.tpl">
<!-- add link to your page -->
<operation error="log">
<search><![CDATA[<li><?php echo $text_product; ?></li>]]></search>
<add position="after"><![CDATA[
<li>Hello World</li>
]]></add>
</operation>
</file>
I want to add some content in footer file using VQMod my XML file has the following content but it's not working
<code>
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>VQMOD CODE test data</id>
<version>1.0</version>
<vqmver>2.0.1</vqmver>
<author>authore name</author>
<file name="catalog/view/theme/default/template/common/footer.tpl">
<operation error="skip">
<search position="after"><![CDATA[
</footer>
]]></search>
<add><![CDATA[
this is test content
]]></add>
</operation>
</file>
</modification>
</code>
what is version of your opencart ?
it's dependent of your footer.tpl content. you need to make sure that </footer> is available in footer.tpl
and also you need to check in vqmod/logs you will see error log there.
Can you tell me if any custom theme is applied on top of your default opencart theme?
Edit :
Try this code, it'll work for you.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE modification [
<!ENTITY adminFolder "admin">
<!ENTITY themeFolder "default">
]>
<modification>
<version>1.0</version>
<vqmver>2.X</vqmver>
<author>umesh</author>
<file name="catalog/view/theme/&themeFolder;/template/common/footer.tpl">
<operation info="To add custom data at footer">
<search position="after" ><![CDATA[
</footer>
]]></search>
<add><![CDATA[
test content
]]></add>
</operation>
</file>