Skip to content

Instantly share code, notes, and snippets.

@almonk
Created June 2, 2011 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save almonk/1004219 to your computer and use it in GitHub Desktop.
Save almonk/1004219 to your computer and use it in GitHub Desktop.
Facebook Like module for Processwire
<div class="page">
<h1><?=$page->title?></h1>
<h3><?=$page->created?></h3>
<?=$page->body?>
<?=$modules->get('FacebookLike')->render();?>
</div>
<?php
class FacebookLike extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'Facebook Like Button',
'version' => 101,
'summary' => 'Display Facebook like buttons on your Processwire site.',
'href' => 'http://www.alasdairmonk.com',
'singular' => false,
'autoload' => false,
);
}
public function init() {
$this->set('url', '');
$this->set('layout', 'button_count');
$this->set('showFaces', 'false');
$this->set('width', '150');
$this->set('height', '21');
$this->set('font', 'Arial');
}
public function ___render() {
// If there's no url supplied, we'll assume the user means the current page
if(!$this->url) $this->url = $this->page->url;
// Build the iframe
$iframe = '<iframe src="http://www.facebook.com/plugins/like.php?href='.$this->url.'&amp;layout='.$this->layout.'&amp;show_faces='.$this->showFaces.'&amp;width='.$this->width.'&amp;action=like&amp;font='.$this->font.'&amp;colorscheme=light&amp;height='.$this->height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$this->width.'px; height:'.$this->height.'px;" allowtransparency="true"></iframe>';
return $iframe;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment