Adding custom field to OpenCart admin with VQmod - opencart

Trying to add a short description field to the category pages in OpenCart back office. Have multiple instances of VQmod XML working fine in controllers and models but trying to use the below to add the field to the category page appears to be doing nothing at all. Nothing gets added/replaced at all in the category_form.tpl.
<!-- This adds the short description field to the admin category page -->
<file name="admin/view/template/catalog/category_form.tpl">
<operation>
<search position="replace"><![CDATA[ <tr>
<td><?php echo $entry_description; ?></td>
<td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
</tr>]]></search>
<add><![CDATA[ <tr>
<td><?php echo $entry_short_description; ?></td>
<td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
</tr>
<tr>
<td><?php echo $entry_description; ?></td>
<td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
</tr>]]></add>
</operation>
</file>
There is clearly a better approach to this as I don't think I should be trying to replace all this code here but if I anyone could kindly check that code over and point out where I've gone wrong, that would be great. Thanks.
Update
My XML code is wrapped in <modification> </modification> by the way....
I have tried using offset and referred to the VQmod documentation but still am unable to get this right...
I have tried:-
<file name="admin/view/template/catalog/category_form.tpl">
<operation>
<search position="replace" offset="1"><![CDATA[<td><?php echo $entry_description; ?></td>]]></search>
<add><![CDATA[ <tr>
<td><?php echo $entry_short_description; ?></td>
<td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
</tr>
<tr>
<td><?php echo $entry_description; ?></td>
<td><textarea name="category_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description'] : ''; ?></textarea></td>
</tr>]]></add>
</operation>
</file>

First whole code should be wrapped in
<modification>
<file ...>
....
</file>
</modification>
Second you can't search multiple lines you can search particular line and then use offset attribute
for your case use
<search position="replace" offset="1"><![CDATA[ <td><?php echo $entry_description; ?></td>]]></search>
refer to vQmod documentation.

Related

How do I fix Unexpected '>' Error?

I am getting this error:
Parse error: syntax error, unexpected '>' in
C:\xampp\htdocs\jagan\display.php on line 40
Here is my code:
<html>
<head><title> Display Student Results </title></head>
<body>
<form action="display.php method="post">
<table>
<tr>
<td>Enter Hallticket Number:
<td><input type="number" name="hno">
</tr>
<tr>
<td><input type="submit" name="btnsearch" value="search">
</tr>
</table>
</form>
</body>
</html>
<?php
$conn=mysqli_connect("localhost","root","")or die("unable to connect");
mysqli_select_db($conn,"college");
if(isset($_POST['btnsearch']))
{
$hall=$_POST['hno'];
$result=mysqli_connect($conn,"select * from student where hno=$hall");
echo "<h1> Student Results </h1>";
echo "<table border=5>";
echo "<tr>";
echo "<th> hallticket";
echo "<th> Name";
echo "<th> class";
echo "<th> gst";
echo "<th> Tax";
echo "<th> php";
echo "<th> dmdw";
echo "<th> accounts";
echo "</tr>;
while($rows=mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".rows['hno'];
echo "<td>".rows['name'];
echo "<td>".rows['class'];
echo "<td>".rows['gst'];
echo "<td>".rows['tax'];
echo "<td>".rows['php'];
echo "<td>".rows['dmdw'];
echo "<td>".rows['acc'];
echo "</tr>";
}
echo "</table>";
}
?>
You aren't calling the mysql resultset properly, it's "row" not "rows". Here are the docs.
echo "<td>".rows['hno'];
Should be:
echo "<td>".row['hno'];
Also, your HTML table isn't properly formed. Take a look at this resource to understand how to create a table.
You need to close off your <th> and <td> tags like this:
echo "<th>Name</th>";
Here is a great tutorial that will walk you through PHP/MySQL coding. Working your way through that first will mean less trips here to SO seeking help.

opencart 1.5.6.4 Add image in the middle of category list

I want to show an image or banner in the middle of product category list page. So if there are 10 products in the product category list then it will show 5 product, and then the image, and then the rest 5 product.
Can anybody show me how to do this? Thank you
Open this file:
catalog/view/theme/default/template/product/category.tpl
find foreach for products:
<?php foreach ($products as $product) { ?>
create a variable as a counter before foreach:
then go to the end of foreach (line 99):
<?php } ?>
add following code before it:
<?php if($i == 5){ ?>
<p>here is place for image</p>
<?php } $i++; ?>
Here is full code for foreach section:
<?php $i = 1; foreach ($products as $product) { ?>
<div>
<?php if ($product['thumb']) { ?>
<div class="image"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></div>
<?php } ?>
<div class="name"><?php echo $product['name']; ?></div>
<div class="description"><?php echo $product['description']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
<div class="cart">
<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
</div>
<div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
</div>
<?php if($i == 5){ ?>
<p>here is place for image</p>
<?php } $i++; ?>
<?php } ?>

How to get related products in product tabs in opencart

I created a extra tab and custom design for related products in products page. I want to get product name,price and to add to cart,image in a loop. In related product tab check this url I am working on that http://efurnish.co.uk/index.php?route=product/product&path=86&product_id=58
<div class="product-related box">
<div class="box-heading"><span><?php echo $tab_related; ?> (<?php echo count($products); ?>)</span></div>
<div class="box-content products-block">
<?php foreach ($pr
oducts as $i => $product) { $i=$i+1; ?>
<?php if( $i%$cols == 1 && $cols > 1 ) { ?>
<div class="row product-related row-product">
<?php } ?>
<div class="col-lg-<?php echo $span;?>">
<div class="product-block">
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>"
title="<?php echo $product['name']; ?>"
alt="<?php echo $product['name']; ?>"/></a>
</div>
<?php } ?>
<div class="name"><?php echo $product['name']; ?></div>
<div class="group-item">
<?php if ($product['rating']) { ?>
<div class="rating"><img
src="catalog/view/theme/<?php echo $this->config->get('config_template');?>/image/stars-<?php echo $product['rating']; ?>.png"
alt="<?php echo $product['reviews']; ?>"/></div>
<?php } ?>
<div class="price-cart">
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span
class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
<div class="cart">
<input type="button" value="<?php echo $button_cart; ?>"
onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"/>
</div>
</div>
</div>
<span class="wishlist"><a class="icon-heart" onclick="addToWishList('<?php echo $product_id; ?>');" data-placement="top" data-toggle="tooltip" data-original-title="<?php echo $button_wishlist; ?>"><span><?php echo $button_wishlist; ?></a></span></span>
<span class="compare"><a class="icon-retweet" onclick="addToCompare('<?php echo $product_id; ?>');" data-placement="top" data-toggle="tooltip" data-original-title="<?php echo $button_compare; ?>"><span><?php echo $button_compare; ?></a></span></span>
</div>
</div>
<?php if( $cols > 1 && ($i%$cols == 0 || $i==count($products)) ) { ?>
</div>
<?php } ?>
I am using this design http://bootsnipp.com/snippets/featured/store-product-layout
There is an option for related products in the product form in the admin panel. You can add related product there to show in the product tab.
To Add Related Products to a product:
In OpenCart admin panel navigate to Catalog -> Products
Search for the product you would like to add related products. Click
Edit link to edit it.
Choose Link tab and scroll down until you see the "Related Products" field.
Start typing a product name in that field and OpenCart will drop
down a list of products that start with whatever letters you have
typed in.
Click on the product you want to add as a related product. You will
see it added to the box below.
Repeat step 4-5 for others product you want to add.
Click on save button
Related products will be added to your product page.

how to add extra tab without any extension in product page in opencart

how to add extra tab without any extension in product page in opencart
may be this is the code for extra tabs any one help? regards
<div class="tabs-group"> <div id="tabs" class="htabs clearfix">Delivery
<?php if ($attribute_groups) { ?>
<?php echo $tab_attribute; ?>
<?php } ?>
<?php if ($review_status) { ?>
<?php echo $tab_review; ?>
<?php } ?>
<?php if( $productConfig['enable_product_customtab'] && isset($productConfig['product_customtab_name'][$languageID]) ) { ?>
<?php echo $productConfig['product_customtab_name'][$languageID]; ?>
<?php } ?>
</div>
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
<?php if ($attribute_groups) { ?>
<div id="tab-attribute" class="tab-content">
<table class="attribute">
<?php foreach ($attribute_groups as $attribute_group) { ?>
<thead>
<tr>
<td colspan="2"><?php echo $attribute_group['name']; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php } ?>
</tbody>
<?php } ?>
</table>
</div>
<?php } ?>
may be this is the code for extra tabs any one help? regards
Add a link to div id="tabs" with a href to your custom tab's id
<div class="tabs-group">
<div id="tabs" class="htabs clearfix">
Delivery
My Tab //Your custom tab
....
Then add your tab div after
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
<div id="tab-my-tab" class="tab-content">Your html content goes here</div>

Opencart VqMod Error

i have opencart 1.5.5.1 web site with VqMod(latest)
Vqmod running fine but i had a problem with one xml file.
xlm file has following lines
<file name="admin/view/template/common/header.tpl">
<operation>
<search position="replace" offset="8"><![CDATA[
<ul class="right" style="display: none;">
]]></search>
<add><![CDATA[
<ul class="right" style="display: none;">
<li id="store"><a onClick="window.open('<?php echo $store; ?>');" class="top">
but result was shown below.
File Name : admin/view/template/common/header.tpl(5)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): <ul class="right" style="display: none;">
there is a line <ul class="right" style="display: none;">in header.tpl but xml code is not working
Add this code for your replace you want hear:
<file name="admin/view/template/common/header.tpl">
<operation>
<search position="replace"><![CDATA[
<li id="store"><?php echo $text_front; ?>
]]></search>
<add><![CDATA[
<li id="store"><a onClick="window.open('<?php echo $store; ?>');" class="top"><?php echo $text_front; ?></a>
]]>
</add>
</operation>
</file>
This value " <ul class="right" style="display: none;">" is not exactly on this file
admin/view/template/common/header.tpl
Perhaps any other extension changes this file.
Also, you can try to quit this part - offset="8" , here:
<search position="replace" offset="8">
replace for:
<search position="replace">
I tried this, and it is good.