- Posts: 5
COMMUNITY FORUM
Open Graph protocol tags in templates articles K2
- Andrii Natalukha
- Topic Author
- Offline
- New Member
<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 );
Please Log in or Create an account to join the conversation.
- troponin
- Offline
- Platinum Member
- Posts: 398
Log in or Create an account to join the conversation.
- Andrii Natalukha
- Topic Author
- Offline
- New Member
- Posts: 5
I found a post:
JoomlaWorksPermalink Reply by JoomlaWorks on April 27, 2011 at 11:17pm
Just a heads up that we plan to add Facebook meta tags in v2.5 of K2.
Why has not it? :(
Please Log in or Create an account to join the conversation.
- Matthew Gray
- Offline
- New Member
- Posts: 13
Just a quick one...how can it be changed so that I can choose the 'S' or 'M' sized image instead of the document image?
Cheers,
Matt
Please Log in or Create an account to join the conversation.