Adding the Facebook "Like Box"
PermalinkI know there are probably add-on from the marketplace, but since facebook gives you all these code options to insert on your page, I figured it would be a breeze to add it to C5. Any thoughts?
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
*Note, it says: "Include the JavaScript SDK on your page once, ideally right after the opening <body> tag."
Basically within the body of the default theme page, just after the body tag you add that code and then put the other in a HTML block.
That's what I normally do.
1. created a new theme folder based on the default theme
2. opened up the default.php page found in the theme folder
3. added the facebook javascript code after the body tag
4. installed and applied the theme
5. added an html block and pasted the facebook html into it
What might I still be doing wrong?
Btw, if the default.php theme file contains the following, where do I exactly put this javascript code?
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>
<div id="central">
<div id="sidebar">
<?php
$as = new Area('Sidebar');
$as->display($c);
?>
</div>
<div id="body">
<?php
$a = new Area('Main');
$a->display($c);
?>
</div>
<div class="spacer"> </div>
</div>
<?php $this->inc('elements/footer.php'); ?>
Elements folder, header.php has the body tag
xampp\htdocs\concrete\themes\default\elements
The simplest method, avoiding editing the header.php would be to add the required Javascript to the "header extra content" on the theme default pages. Header extra content is a custom atttribute in page properties. You get to this from the C5 dashboard pages and themes / inspect / page types / then edit the default pages properties.
Then add the like button code as an HTML block on the pages where you want it.
The better method is to edit header.php. On a hosted install you need either an FTP program acess the site files directly, or the file manager in Cpanel if your host runs that. You cannot edit those files inside C5. If all this sounds like gibberish, stick with the first method.
I am trying to install on my website the Facebook "Likebox" and have been reading your instructions in this post.
However, I am not sure where to paste the Facebook code in the header.php file because I have these lines of code in the file:
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<!DOCTYPE html>
<html lang="<?php echo LANGUAGE?>">
<head>
<?php Loader::element('header_required'); ?>
<!-- Site Header Content //-->
<link rel="stylesheet" href="<?php echo $this->getThemePath(); ?>/css/reset.css" />
<link rel="stylesheet" href="<?php echo $this->getThemePath(); ?>/css/text.css" />
<link rel="stylesheet" href="<?php echo $this->getThemePath(); ?>/css/960_24_col.css" />
<link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('main.css')?>" />
<link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('typography.css')?>" />
<link href='http://fonts.googleapis.com/css?family=Merriweather:400,700,900,300' rel='stylesheet' type='text/css' />
</head>
<body>
<!--start main container -->
<div id="main-container" class="container_24">
<div id="header">
<?php
$a = new GlobalArea('Site Name');
$a->display();
?>
<?php
$a = new GlobalArea('Header Nav');
$a->display();
?>
<div id="header-image">
<?php
$a = new Area('Header Image');
$a->display($c);
?>
</div>
</div>
<div class="clear"></div>
FYI, I have the header.php file in a folder where I created a copy of the Greek Yogurt template and place it under: Theme -> My Theme -> Element
Thank you for your assistance.
Enzo
The advantage of the add-ons is easier site wide management of the links, and you can include things like Google+ and Twitter easily. I've tried a couple of different free ones and they are all good. There is also AddThis to consider, or ShareIt add-ons.
I will post some of the add ons I've tried in a minute.
The link you provided landed on a page not found page.