My Code is in a single xml file.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created using vQModerator's XML Generator by The Wizard of Osch for http://www.crystalcopy.nl //-->
<!-- (Based on vQmod XML Generator by UKSB - http://www.opencart-extensions.co.uk) //-->
<modification>
<id><![CDATA[vQModerator Installation]]></id>
<version><![CDATA[1.1.6]]></version>
<vqmver><![CDATA[2.4.1]]></vqmver>
<author><![CDATA[Nidhishanker Modi]]></author>
<file name="catalog/view/theme/shopitout/template/common/header.tpl" error="abort">
<operation info="">
<search position="Replace" offset="" ><![CDATA[<img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" />]]></search>
<add><![CDATA[<img src="image/data/my_logo.png" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" />]]></add>
</operation>
</file>
<file name="catalog/controller/module/slideshow.php" error="">
<operation info="">
<search position="After" ><![CDATA[
$results = $this->model_design_banner->getBanner($setting['banner_id']);
]]></search>
<add><![CDATA[echo "Testing Data to hold screen"; exit; ]]></add>
</operation>
</file>
</modification>
Now Friends the second file tag is replacing my search data always. Even i am not giving postion="replace".
where i am wrong please give me suggestions.
There is an error in your first file tag code. Most probably:
Wrong file location (catalog/view/theme/shopitout/template/common/header.tpl) .
Or mentioned search code doesn't exist in catalog/view/theme/shopitout/template/common/header.tpl
Proof for the above statements:
Move the second file tag to first - Working.
Or remove the error="abort" parameter form first file tag - 2nd file code Working
if you still can't find the error, then refer the section under the heading - Opencart Vqmod xml file not working?? in https://sankartypo3.wordpress.com/2013/11/25/opencart-vqmod-tutorial/
Have a nice day!!
Related
Below is my PHP code and XML file, I have been trying with so many different echos to loop through my images in my XML file to display each image to correct product but can only display the first image to all three products.
XML code:
<my_products>
<product>
<id>1</id>
<image> csuT.jpg</image>
<name>Champion T-Shirt</name>
<price>18.00</price>
<description>
Get the perfect look to let everyone know you are a stylish fan!
</description>
</product>
<product>
<id>2</id>
<image> webBook.jpg</image>
<name>C# Programming: Analysis to Program Design</name>
<price>192.00</price>
<description>
Your hands-on guide to Microsoft Visual C# fundamentals with Visual Studio 2017
</description>
</product>
<product>
<id>3</id>
<image> calcPic.jpg</image>
<name>Calculator TI-BAII Plus 10DIG/24CASH</name>
<price>39.00</price>
<description>
Performs common math as well as various financial functions
</description>
</product>
</my_products>
PHP code:
$xml = simplexml_load_file($file);
$script_images="";
$script_products="";
$script_product_prices="";
//Loop through the products defined in the products.xml file
foreach ($xml->product as $r)
{
$script_images.="products[".($r->id)."]=\"".($r->image)."\";\n";
$script_products.="products[".($r->id)."]=\"".($r->name)."\";\n";
$script_product_prices.="product_prices[".($r->id)."]=\"".($r->price)."\";\n";
?>
<div>
<p class="lead">
<h3 class="pull-right no-top-margin"><?php echo $currency_symbol;?><?php echo $r->price;?></h3>
<h3><?php echo "<image src='csuT.jpg' 'calcPic.jpg' 'webBook.jpg'/>";?></h3>
</p>
<h3><?php echo $r->name;?></h3>
</p>
<p>
<?php echo $r->description;?>
</p>
<br/>
<?php
//If there is details link set for the product, show a Details button
if(trim($r->details_link)!="")
{
?>
<a target="_blank" href="http://<?php echo str_replace("http://","",trim($r->details_link));?>"</a>
<?php
}
?>
<a class="btn btn-xs btn-info" href="javascript:AddToCart(<?php echo $r->id;?>)">Add to Cart</a>
</div>
<hr/>
<?php
}
?>
<script>
var currency_symbol="<?php echo $currency_symbol;?>";
var products=Array();
<?php echo $script_images;?>
var product_images=Array();
<?php echo $script_products;?>
var product_prices=Array();
<?php echo $script_product_prices;?>
</script>
You just need to extract the image from the XML (the same way as done for the Javascript) and I've added a trim() to remove any spaces round the field...
<h3><?php $image = trim($r->image);
echo "<image src='$image'/>";?></h3>
Also add trim to...
$script_products.="products[".($r->id)."]=\"".($r->name)."\";\n";
What is this? :
<h3><?php echo "<image src='csuT.jpg' 'calcPic.jpg' 'webBook.jpg'/>";?></h3>
your src attribute is static and you must change it
I have this code that works with Opencart 1.5, it adds the Shipping Method to the order list, I have changed it to flag on Express Shipping, however I don't really know what I am missing to make it work for Opencart 2.0.
<modification>
<id>Shipmethod</id>
<version>1.0.</version>
<vqmver>2.1.x</vqmver>
<author></author>
<file name="admin/model/sale/order.php">
<operation>
<search position="replace" regex="true"><![CDATA[~SELECT o.order_id,~]]></search>
<add><![CDATA[SELECT o.order_id, o.shipping_method,]]></add>
</operation>
</file>
<file name="admin/controller/sale/order.php">
<operation>
<search position="before"><![CDATA['action' => $action]]></search>
<add><![CDATA['shipping_method' => $result['shipping_method'],]]></add>
</operation>
</file>
<file name="admin/view/template/sale/order_list.tpl">
<operation>
<search position="before"><![CDATA[<td class="left"><?php if ($sort == 'o.date_added') { ?>]]></search>
<add><![CDATA[
<td style="width:125px">Express Shipping</td>
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[<td><input type="text" name="filter_date_added"]]></search>
<add><![CDATA[<td></td>]]></add>
</operation>
<operation>
<search position="before"><![CDATA[<td class="left"><?php echo $order['date_added']; ?></td>]]></search>
<add><![CDATA[<td class="left" style="color:red;"><?php if ($order['shipping_method'] === "3. UK Express Delivery") {echo "YES";};?></td>
]]></add>
</operation>
</file>
</modification>
Any help to make it work with Opencart 2.0 would be great :)
FYI, Opencart v2.0.0.0 is slightly different from version 1.5.6.4 or below.
So you have to modified your vqmod xml file. You can check with following code
<modification>
<id>Shipmethod</id>
<version>1.0.</version>
<vqmver>2.1.x</vqmver>
<author></author>
<file name="admin/model/sale/order.php">
<operation>
<search position="replace" regex="true"><![CDATA[~SELECT o.order_id,~]]></search>
<add><![CDATA[SELECT o.order_id, o.shipping_method,]]></add>
</operation>
</file>
<file name="admin/controller/sale/order.php">
<operation>
<search position="before"><![CDATA['status' => $result['status'],]]></search>
<add><![CDATA['shipping_method' => $result['shipping_method'],]]></add>
</operation>
</file>
<file name="admin/view/template/sale/order_list.tpl">
<operation>
<search position="before" offset="0"><![CDATA[<td class="text-left"><?php if ($sort == 'status') { ?>]]></search>
<add><![CDATA[
<td style="width:125px">Express Shipping</td>
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[<td class="text-left"><?php echo $order['status']; ?></td>]]></search>
<add><![CDATA[<td class="left" style="color:red;"><?php if ($order['shipping_method'] === "Flat Shipping Rate") {echo "YES";};?></td>
]]></add>
</operation>
</file>
Please take a look at the following xml file in the vqmod folder.
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Drop Shipping</id>
<version>2.0.0</version>
<vqmver required="true">2.4.0</vqmver>
<author>South Coast Hosting Services (Pty) Ltd</author>
<file name="admin/language/*/common/menu.php">
<operation error="log">
<search><![CDATA[// Text]]></search>
<add position="after"><![CDATA[
$_['text_gdropship_menu'] = 'Drop Shipping';
$_['text_gdropship_setup'] = 'Drop Shipping Setup';
]]></add>
</operation>
</file>
<file name="admin/controller/common/menu.php">
<operation error="log">
<search ><![CDATA[$this->load->language('common/menu');]]></search>
<add position="after"><![CDATA[
$data['text_gdropship_setup'] = $this->language->get('text_gdropship_setup');
$data['text_gdropship_menu'] = $this->language->get('text_gdropship_menu');
]]></add>
</operation>
<operation error="log">
<search><![CDATA[$data['home'] = $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL');]]></search>
<add position="before"><![CDATA[
$data['gdropshipmenu'] = $this->url->link('custom/gdropship', 'token=' . $this->session->data['token'], 'SSL');
$data['home'] = $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
</file>
<file name="admin/view/template/common/menu.tpl">
<operation error="log">
<search><![CDATA[<li id="system"><a class="parent"><i class="fa fa-cog fa-fw"></i> <span><?php echo $text_system; ?></span></a>]]></search>
<add position="before"><![CDATA[<li><a class="parent"><i class="fa fa-share-alt fa-fw"></i><span><?php echo $text_gdropship_menu; ?><span></a>
<ul>
<li><?php echo $text_gdropship_setup; ?></li>
</ul><li id="system"><a class="parent"><i class="fa fa-cog fa-fw"></i> <span><?php echo $text_system; ?></span></a>]]></add>
</operation>
</file>
</modification>
This runs perfectly, linking to an admin page create in this question. You will see that the position tags contain 'after' and 'before' options. My problem is (besides taking all day to figure this out and do these few lines) is that both these tags seem to replace instead of doing a before or after. Changing them to replace has no effect. Hence I just included the code I was 'After-ing'.
So my question is have I done something wrong with the above code? I would just like to clarify before proceeding with development so it does not bite me down the line. It could be just another OC2 newbie.
Thank you.
PS Perhapse considering what's new a new tag for Opencart2 is warranted?
There is nothing wrong with your vQmod searches or replaces. The issue is you've formatted the search and replace parameters to those of OCMod, with the position="XXX" in the <add> tag instead of the <search> tag as per vQmod's format. Swapping those should fix the problem
I am new to Open cart and working with VQmod and tried this code for editing my header logo and some text.
<file name="catalog/view/theme/shopitout/template/common/header.tpl" error="abort">
<operation info="">
<search position="Replace" offset="" ><![CDATA[<img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" />]]></search>
<add><![CDATA[<img src="image/data/my_logo.png" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" />]]></add>
</operation>
</file>
</modification>
Now i want to write such code for edit a controller and model.
please tell how can we make such code or xml for model and controller.
In between </file> and </modification> tags add:
<file name="###File name with path of controller/ model file ###" >
<operation info="###Operation Info###" >
<search position="###Search/Replace filter###" regex="false" ><![CDATA[###Search Code###]]></search>
<add><![CDATA[
###Add Code###
]]></add>
</operation>
</file>
Reference link: Opencart Vqmod tutorial
I want to add a new submenu under the catalog in the admin of the opencart using Vqmod. Here is my code:
<modification>
<id>add menu</id>
<author>XXX</author>
<version>2.3</version>
<vqmver>1.0.8</vqmver>
<!-- OPTION CONTROLLER -->
<file name="admin/controller/common/header.php">
<operation>
<search position="after"><![CDATA[
$this->data['text_newmenu'] = $this->language->get('text_newmenu');
]]></search>
<add><![CDATA[
$this->data['text_newmenu'] = $this->language->get('text_newmenu');
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
$this->data['doctor'] = $this->url->link('catalog/doctor', 'token=' . $this->session->data['token'], 'SSL');
]]></search>
<add><![CDATA[
$this->data['newmenu'] = $this->url->link('catalog/newmenu', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
</file>
<!-- OPTION LANGUAGE -->
<file name="admin/language/english/common/header.php">
<operation>
<search position="after"><![CDATA[
$_['text_zone'] = 'Zones';
]]></search>
<add><![CDATA[
$_['entry_newmenu'] = 'Wow sexy';
]]></add>
</operation>
</file>
<!-- header.tpl for new menu-->
<file name="admin/view/template/common/header.tpl">
<operation>
<search position="after"><![CDATA[
<li><?php echo $text_doctor; ?></li>
]]></search>
<add><![CDATA[
<li><?php echo $text_newmenu; ?></li>
]]></add>
</operation>
</file>
<modification>
But there is an error comes in DOM UNABLE TO LOAD: /opt/lampp/htdocs/work/oc/vqmod/xml/addmenu.xml
Does any one know whats the problem in my code?
I Was facing the similar problem. I had given the permission to the file. But still it was saying unable to load. After little research i found that it had admin permission and no read permission from others, which can be given by :
sudo chmod a+r filename
if you want to give to entire directory, then
sudo chmod -R a+r directory/
and this fixed my bug..
Hope it helps
addmenu.xml please validate this xml using an xml validator like this
http://www.xmlvalidation.com/
The error is because xml file is not a valid one
If this doesn't solve the problem , then try adding
<?xml version="1.0" encoding="UTF-8"?>
at top of the xml
Do you have any non-standard characters in your author tag such as á é í ó ú? If so, make sure you put them in CDATA tags as well as putting the
<?xml version="1.0" encoding="UTF-8"?>
header at the very start of the document (with absolutely nothing before it)