Skip to content

Commit

Permalink
* add basic OpenGraph support. See http://www.elkarte.net/community/i…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaadickerson committed Dec 27, 2015
1 parent 3076447 commit 48c1630
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sources/controllers/Display.controller.php
Expand Up @@ -654,6 +654,9 @@ public function action_display()
$this->_template_layers->add('quickreply');
$this->_template_layers->add('pages_and_buttons');

// Give social networks some more info about the page
$this->openGraphHeaders();

// Allow adding new buttons easily.
call_integration_hook('integrate_display_buttons');
call_integration_hook('integrate_mod_buttons');
Expand Down Expand Up @@ -880,4 +883,16 @@ public function prepareDisplayContext_callback($reset = false)

return $output;
}

public function openGraphHeaders()
{
global $context;

$context['html_headers'] .= '
<meta property="og:url" content="' . $context['canonical_url'] . '" />
<meta property="og:sitename" content="' . $context['forum_name'] . '" />
<meta property="og:type" content="article" />
<meta property="og:title" content="' . $context['page_title'] . '" />
';
}
}
16 changes: 16 additions & 0 deletions sources/controllers/Profile.controller.php
Expand Up @@ -187,6 +187,8 @@ public function action_index()
// Set the page title if it's not already set...
if (!isset($context['page_title']))
$context['page_title'] = $txt['profile'] . (isset($txt[$this->_current_area]) ? ' - ' . $txt[$this->_current_area] : '');

$this->openGraphHeaders();
}

/**
Expand Down Expand Up @@ -786,4 +788,18 @@ private function _check_password($check_password)
}
}
}


public function openGraphHeaders()
{
global $context;

$context['html_headers'] .= '
<meta property="og:url" content="' . $context['canonical_url'] . '" />
<meta property="og:sitename" content="' . $context['forum_name'] . '" />
<meta property="og:type" content="article" />
<meta property="og:title" content="' . $context['page_title'] . '" />
<meta property="og:image" content="' . $context['member']['avatar']['href'] . '" />
';
}
}

0 comments on commit 48c1630

Please sign in to comment.