How to change <html> tag and add <meta ... /> tags from productdetails view?

Started by borro, November 05, 2015, 11:49:49 AM

Previous topic - Next topic

borro

Hello, friends

I'm trying to embed open graph protocol to a product detail pages.

How can I change the begining <html> tag of a product page to something like <html prefix="og: http://ogp.me/ns#"> from the components/com_virtuemart/views/productdetails/tmpl/default.php file?
The second question is how to add a few <meta ... /> tags to the <head> section of a page from the same php file?

VM 3.0.9
Wish you happiness!


borro

Wish you happiness!

PRO

you mean for the joomla template?

that will have to be done in the template

lekreator

Borro, i made this to my site.
After this hack, i just paste product url in facebook timeline.

1) override the file: /components/virtuemart/views/produtcdetails/tmpl/default.php in your template folder (such as /templates/YOUTEMPLATE/html/productdetails/default.php)
2) in your file productdetails/default.php, insert this code right after initial "<?php" tag:

$og_type = 'article';
$og_url = JURI::current();
$og_image = JRoute::_(JURI::base().$this->product->images[0]->file_url);
$og_desc = $this->product->product_s_desc;
$og_title = $this->product->product_name;

$app =& JFactory::getApplication();
$og_sitename = $app->getCfg('sitename');

$doc = JFactory::getDocument();

$doc->addCustomTag('<meta property="og:title" content="'.$og_title.'"/>');
$doc->addCustomTag('<meta property="og:image" content="'.$og_image.'"/>');
$doc->addCustomTag('<meta property="og:description" content="'.$og_desc.'"/>');
$doc->addCustomTag('<meta property="fb:app_id" content="INSERT YOUR FB APP NUMBER HERE"/>');

Its all. this reproduces like this:



then enter in this url and test your open graph:

https://developers.facebook.com/tools/debug/og/object/

see my results for a product:




borro

Hello, lekreator!
Thank you very much!
you said:
Quote from: lekreator on November 16, 2015, 15:45:45 PM
$doc->addCustomTag('<meta property="fb:app_id" content="INSERT YOUR FB APP NUMBER HERE"/>');
Do I have to create some app necessarily? If so what type of app should i create to make FB to undestand my opengraph protocol realization?
I have already have a one app for my site and I'm using it to enable fb comments at site. Can i use its APP ID?

It looks like you are not changing <html> tag. Is that fine?
Wish you happiness!

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation