Skip to content

Instantly share code, notes, and snippets.

@biwerr
Created June 30, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biwerr/80615d98325afad86849 to your computer and use it in GitHub Desktop.
Save biwerr/80615d98325afad86849 to your computer and use it in GitHub Desktop.
Contao Facebook Meta Tags News Article
// News Detail Template (news_full)
<?php
$ogimage = $this->getImage( $this->urlEncode( $this->singleSRC ), 512, 512 , 'box' );
$GLOBALS['og:title'] = $this->newsHeadline;
$GLOBALS['og:description'] = $this->teaser;
$GLOBALS['og:image'] = $this->Environment->base . $ogimage;
?>
// Page Templae (fe_page)
<?php
if($GLOBALS['og:title'])
echo '<meta property="og:title" content="'.$GLOBALS['og:title'].'" />';
if($GLOBALS['og:description'])
echo '<meta property="og:description" content="'.$GLOBALS['og:description'].'" />';
if($GLOBALS['og:image'])
echo '<meta property="og:image" content="'.$GLOBALS['og:image'].'" />';
else
echo '<meta property="og:image" content="{{env::url}}/files/turnbar/turnbar_logo_small.png" />';
?>