Opencart meta title in every page - opencart

I have a script for vqmod opencart made in this way:
<modification>
<file name="catalog/view/theme/*/template/common/header.tpl">
<operation>
<search position="replace"><![CDATA[<title><?php echo $title; ?></title>]]></search>
<add><![CDATA[<title><?php
$separator=" | ";
$store_name=$this->config->get('config_name');
if(trim($store_name)!=trim($title))
echo $title.$separator.$store_name;
else
echo $title;
?></title>]]></add>
</operation>
</file>
</modification>
I would like to show in every page not the website name (config_name), but the homepage title that is different and more complete. Moreover it is different for every language of my site. Can you help me in some way?
Thank you

thanks for the answer. I would like to add at the end of the meta title of every page (all of them, products, categories, informations etc) a string of words of my choice. For example if the title is " #productname, #category, #brand " , I want it to be " #productname, #category, #brand - #mysitename #mysitedescription". The problem is that #mysitename #mysitedescription have to be different for every language automatically.
I hope to have well explained the problem

Related

how to remove advertisement in opencart admin panel

How to remove opencart Advertisement in admin panel.
Here you see the Adverisement:
In your OpenCart installation go to file
/admin/controller/extension/extension/promotion.php
and add replace this code on line 18
return $response;
with this
return '';
This will remove any promotion you see in your OpenCart admin panel.
Enjoy!
Dmitriy Zhuk's answer is the easiest to apply.
An alternative if you want the change as a mod is to use something like this:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Hide promotions in admin panel</name>
<code>skippromotion</code>
<version>3.0x</version>
<author>TH</author>
<link>https://stackoverflow.com/questions/55702884</link>
<file path="admin/controller/extension/extension/*.php">
<!-- Remove the 'promotions' feature -->
<operation error="log">
<search><![CDATA[$data['promotion'] = $this->load->controller('extension/extension/promotion');]]></search>
<add position="replace"><![CDATA[
$data['promotion'] = '';
]]></add>
</operation>
</file>
</modification>
Save it as 'install.xml', zip it up as 'skippromotion.ocmod.zip' and upload it using the 'Installer' in the admin panel - then go to 'Modifications', enable the mod and refresh your mod cache. The ads should disappear from the admin panel.
Note that this mod works in a different way to Dmitriy Zhuk's answer, it's replacing every call to admin/controller/extension/extension/promotion.php rather than the value that script returns.
Obviously you'll need to disable the mod and change OPENCART_SERVER in your config if you ever start your own farm of OpenCart installations and want to advertise to your users.
Perhaps better yet if your're going the edit route like I did:
<?php
class ControllerExtensionExtensionPromotion extends Controller {
public function index() {
// MOD Eliminate Admin promotions - just return nothing.
// we don't need to curl anything and might make site a touch faster
return '';
}
}

opencart asks me to login again when i use the image manager

I've been running open cart on my server for a client, but it's acting rather strange. when we try to access the images to attach to a product, we get this this login image inside the 'image manager' pop up window. and the buttons to Rename, new folder and so on change color.
I can't seem to find anything on google, have you seen this before or have any idea if i got hacked or something happened?
I'm running version 1.5.6.3
After i click to add ANY image it adds that login segment. and I can try to log in, but I haven't tried.
This is the way it pops up first, THEN it turns into the image above.
This is the correct way it should stay.
Same problem here. It used to work properly for more than a year and it stopped working days ago, without changes or updates to my website. What hosting company are you on? I'm on Bluehost, trying to understand if they changed something...
EDIT: ok I've found a solution here: http://forum.opencart.com/viewtopic.php?f=161&t=93875&start=40
I've created a vqmod file called fix-image-manager.xml and put it in /vqmod/xml, as suggested in that post. This is the content of the file:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>IMAGE MANAGER FIX</id>
<version>1.5.6.1</version>
<vqmver required="true">2.5.0</vqmver>
<author>OpenCart</author>
<file name="admin/view/template/common/filemanager.tpl">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>']]></add>
</operation>
</file>
<file name="admin/view/template/catalog/*">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent($('#' + field).attr('value')) + '&token=<?php echo $token; ?>']]></add>
</operation>
</file>
</modification>
If you don't use vqmod, you should just edit admin/view/template/common/filemanager.tpl and change this line:
'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value')),
to this:
'index.php?route=common/filemanager/image&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>',
and do the same thing in all the files in admin/view/template/catalog/ where the same line is present.
Apparently the &token should be the last parameter. I still can't get why it has worked properly so far and suddenly it stopped working.
I would suggest checking your tokens that are in the address bar of the iframe for the image adding screen, when the tokens are incorrect this problem happens. It is because the system looks at you as a non logged in user.
Go to the file manager page directly from your browser when you logged in to the backend to see if it exists and navigates to correctly.
index.php?route=common/filemanager
Remember to leave the token part in your address bar and just change the above
If it navigates to this page correctly then you will have to find the link to the image iframe and compare the tokens to the ones you are logged in with (see browser address). If it doesn't navigate to this page correctly then you will have to look at the coding for that specific page.

OpenCart show weight units in product page 1.5.6

How can I show the the weight (with units) in product page in 1.5.6.
Example: Weight - 2.5 kg; Weight - 250 mg ...
I've been reading some articles, but nothing working correctly.
You can format weight with Opencart's weight class format() method like this:
$this->weight->format($weight,$weight_class_id);
The getProduct() method already supplies both values you need so you can easily call it from the product controller like so:
$this->data['product_weight'] = $this->weight->format($product_info['weight'],$product_info['weight_class_id']);
Then display $product_weight wherever you want in the tpl as you would any other variable. This will give you exactly what you want but with no space (i.e., '250mg').
If you want more control over the formatting, you can also get only the unit abbreviation (e.g., 'kg', 'oz', 'lb', etc) with the getUnit() method like this:
$this->weight->getUnit($product_info['weight_class_id']);
You could then put them together however you want. If you want a space for instance:
$this->data['product_weight'] = $product_info['weight'] . ' ' . $this->weight->getUnit($product_info['weight_class_id']);
go to catalog/language/english/product/product.php,Find:
$_['text_model'] = 'Product Code:';
Add below code after it
$_['text_weight'] = 'Weight:';
open catalog/controller/product/product.php, Find:
$data['text_stock'] = $this->language->get('text_stock');
Add below code after it:
$data['text_weight'] = $this->language->get('text_weight');
In same file search for the code:
$data['model'] = $product_info['model'];
Paste below code after it:
$data['weight'] = $product_info['weight'];
$tablewunit = $this->db->query("SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE (wcd.weight_class_id = " . $product_info['weight_class_id'] . ") AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
$data['weight_unit'] = $tablewunit->row['unit'];
Now open catalog/view/theme/---yourtheme---/template/product/product.tpl, and find:
<li><?php echo $text_stock; ?> <?php echo $stock; ?></li>
Add below code after it:
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo round ($weight, 2) . ' ' . $weight_unit; ?></td>
<tr>
<?php if ($weight) { ?>
<tr>
<?php } ?>
Thats all
Hello fellow Bulgarian i assume by your name.
If you want to display weight on products it's very simple.
Open your FTP and go to catalog/view/theme/YOURTHEME/template/product and download product.tpl
find this line
<span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span><br />
<?php } ?>
Right after it paste this
<?php
echo round($weight,2). "kg";
?>
(Or paste it where ever you want to see it on the product page.)
after that go to /catalog/controller/product and open product.php
find this line
$this->data['model'] = $product_info['model'];
and right after it paste this line:
$this->data['weight'] = $product_info['weight'];
and you are pretty much done with that.
Hopefully i understood your question correctly.

Opencart how to add php code to product/category description

Does anyone know how to, without purchasing an addon/extension, add php code to the product and category descriptions? If you try to add it automatically gets commented out when you save, e.g. <!-- <?php echo "test" ?> -->
Workaround: For anyone else.. I used borderless iframe to include an external .php file which contained the php code I needed ....

vQmod code syntax

I'm writing vqmod opencart modification and got one problem. There's a basic code:
<operation>
<search position="after"><![CDATA[<?php echo $description; ?></div></div>]]></search>
<add>
<![CDATA[<div class="content"><h2>Testimonials</h2><div class="box-testimonial"><?php echo $description_new; ?></div></div>]]>
</add>
</operation>
So What I want to do is to make some kind of conditional to display the code from only when $description_new is not empty. What will be the syntax in this vqmode code?
Thanks in advance,
Arek
ok i figured out. It seems like it's usual php syntax inside CDATA
<![CDATA[<?php if (isset($this->data['description_new'])) { echo '<div class="content"><h2>Testimonials</h2><div class="box-testimonial">' . $description_new . '</div></div>'; } else { echo ' '; }?>]]>
vQmod simply allows you to insert code just like you would normally into a file, but without actually touching the file contents. So yes using an if statement just like you have is fine. Also, one thing I would point out is you should use as little content as you can for the search portion, that's unique. So for your above code
echo $description;
should be enough to match. It also makes it less likely to break should you use other mods