Hello,
I'm trying to integrate a facebook like button on every product/product page. In order to specify the image shown on facebook I should pass a meta tag <meta property="og:image" content="current-product-thumb.jpg" /> from controller/product/product.php to the <head> section of common/header.tpl
Is it possible to pass a variable from a controller to another controller's view?
The OpenCart version is 1.5.1.3.
Thanks in advance!
VaanBooch
I'm trying to integrate a facebook like button on every product/product page. In order to specify the image shown on facebook I should pass a meta tag <meta property="og:image" content="current-product-thumb.jpg" /> from controller/product/product.php to the <head> section of common/header.tpl
Is it possible to pass a variable from a controller to another controller's view?
The OpenCart version is 1.5.1.3.
Thanks in advance!
VaanBooch
it sure is... but i always grab it in the other controller as well
Cheers
jem
Cheers
jem
Hand Dryers
Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover
Active Member
You mean to get the current product's data in common/header.php again? It's possible, of course, but I wonder if there is a more ellegant way to do it ....Jeremy Fisk wrote:it sure is... but i always grab it in the other controller as well
Dunno... but what i often do is put in a get request for the product ID and then grab the corrosponding info from the databasevaanbooch wrote:You mean to get the current product's data in common/header.php again? It's possible, of course, but I wonder if there is a more ellegant way to do it ....Jeremy Fisk wrote:it sure is... but i always grab it in the other controller as well
Hand Dryers
Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover
Active Member
Thanks Jeremy,
I've made a vqmod and everything went fine. The code is below.
Add in common/header.tpl <head> area:
If we have an active product, its thumbnail is passed to Facebook. If the page is other than product/product, Facebook will use a default image.
I've made a vqmod and everything went fine. The code is below.
Code: Select all
<modification>
<id>Facebook og:image fix</id>
<version>1.0</version>
<vqmver>1.0.8</vqmver>
<author>www.bewebdesign.be</author>
<file name="catalog/controller/common/header.php">
<operation>
<search position="after"><![CDATA[$this->load->model('catalog/product');]]></search>
<add><![CDATA[
if (isset($this->request->get['product_id'])) {
$product_id = $this->request->get['product_id'];
$product_info = $this->model_catalog_product->getProduct($product_id);
$this->load->model('tool/image');
if ($product_info['image']) {
$this->data['og_image'] = str_replace( ' ', '%20', $this->model_tool_image->resize($product_info['image'],100,100) );
} else {
$this->data['og_image'] = 'FULL_PATH_TO_YOUR_DEFAULT_IMAGE';
}
} else {
$this->data['og_image'] = 'FULL_PATH_TO_YOUR_DEFAULT_IMAGE';
}
]]></add>
</operation>
</file>
</modification>
Code: Select all
<?php if ($og_image) { ?>
<meta property="og:image" content="<?php echo $og_image; ?>" />
<?php } ?>
Last edited by vaanbooch on Fri Mar 30, 2012 9:37 pm, edited 1 time in total.
I've installed your xml file and the header code as you discriped but i get the following error.
Can you please guide me how to do this?
I'm using OC 1.5.2.1
Code: Select all
Catchable fatal error: Argument 1 passed to VQModObject::__construct() must be an instance of DOMNode, null given, called in /home/Mysite/public_html/Mysite/vqmod/vqmod.php on line 580 and defined in /home/Mysite/public_html/Mysite/vqmod/vqmod.php on line 127
Can you please guide me how to do this?
I'm using OC 1.5.2.1
There were missing the obligatory <modification>, etc. fields.
I've corrected the code, you can try it now :-)
I've corrected the code, you can try it now :-)
Meanwhile we have made an extended version, which provides:
- Sharing of each Product with it's corresponding Image, Title and Description
- Site Global Image, Title and Description
It can be downloaded here: http://www.opencart.com/index.php?route ... order=DESC
Enjoy!
- Sharing of each Product with it's corresponding Image, Title and Description
- Site Global Image, Title and Description
It can be downloaded here: http://www.opencart.com/index.php?route ... order=DESC
Enjoy!
Who is online
Users browsing this forum: No registered users and 98 guests