How to implement the Open Graph protocol insert tags into your template articles K2?
Here's how it is implemented in templates for GavickPro Joomla-articles:
<html xmlns="www.w3.org/1999/xhtml"
xmlns:og="ogp.me/ns#"
xmlns:fb="www.facebook.com/2008/fbml">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
...
</head>
...
</html>
Here's how it is implemented in templates for GavickPro Joomla-articles:
// OpenGraph support
$template_config = new JConfig();
$uri = JURI::getInstance();
$article_attribs = json_decode($this->item->attribs, true);
$og_title = $this->escape($this->item->title);
$og_type = 'article';
$og_url = $cur_url;
$og_image = '';
$og_site_name = $template_config->sitename;
$og_desc = '';
if(isset($article_attribs)) {
$og_title = ($article_attribs == '') ? $this->escape($this->item->title) : $this->escape($article_attribs);
$og_type = $this->escape($article_attribs);
$og_url = $cur_url;
$og_image = ($article_attribs == '') ? '' : $uri->root() . $article_attribs;
$og_site_name = ($article_attribs == '') ? $template_config->sitename : $this->escape($article_attribs);
$og_desc = $this->escape($article_attribs);
}
$doc = JFactory::getDocument();
$doc->setMetaData( 'og:title', $og_title );
$doc->setMetaData( 'og:type', $og_type );
$doc->setMetaData( 'og:url', $og_url );
$doc->setMetaData( 'og:image', $og_image );
$doc->setMetaData( 'og:site_name', $og_site_name );
$doc->setMetaData( 'og:description', $og_desc );