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
https://docs.joomla.org/JDocument/setMetaData
Quote from: PRO on November 05, 2015, 16:57:36 PM
https://docs.joomla.org/JDocument/setMetaData
thanks a lot. And how can I change the <html> tag on <html prefix="og: http://ogp.me/ns#"> ?
you mean for the joomla template?
that will have to be done in the template
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:
(http://misteriosembeleza.com.br/facebook.png)
then enter in this url and test your open graph:
https://developers.facebook.com/tools/debug/og/object/
see my results for a product:
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?
afaik the app id is optional