Forum

Thread tagged as: Problem, Error, Configuration

Facebook/Twitter og:tags

Added facebook og:tags to head of layout file. Everything appeared ok but og:sitename not being echoed into head of each page. Looks like the

PerchSystem::set_var('sitename',$sitename);

missing from added php code snippet

Added

PerchSystem::set_var('domain',$domain);
PerchSystem::set_var('url',$url);

PerchSystem::set_var('sitename',$sitename);

PerchSystem::set_var('sharing_image',$sharing_image);
PerchSystem::set_var('twittername',$twittername);

and now showing ok. Not sure if this was meant to be pulled from elsewhere but when added works as expected.

Rob Willox

Rob Willox

Rob Willox 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok - I'm not sure what your question is. Which part isn't working, and can you give us some context as to what you're doing?

Hi Drew, no question!

It was an observation and comment in case others had experienced something similar.

Added Open Graph tags as per the guide "Using Page Attributes to add Facebook Open Graph Tags and Twitter Cards"

The site name was not showing looking at page source. Looking at the code it wasn't being defined by a PerchSystem setvar:-

<?php 
$domain        = 'https://'.$_SERVER["HTTP_HOST"];
$url           = $domain.$_SERVER["REQUEST_URI"];
$sitename      = "The name of my website";
$twittername   = "@mytwittername";
$sharing_image = '/images/default_fb_image.jpg';

PerchSystem::set_var('domain',$domain);
PerchSystem::set_var('url',$url);
PerchSystem::set_var('sharing_image',$sharing_image);
PerchSystem::set_var('twittername',$twittername);

perch_page_attributes(array(        
  'template' => 'default.html'    
));
?>

Added it and now showing.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, ok, that helps. It sounds like a few people are having trouble with that, so we may need to rewrite it to make it clearer.