Created
June 2, 2011 10:22
-
-
Save almonk/1004219 to your computer and use it in GitHub Desktop.
Facebook Like module for Processwire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="page"> | |
<h1><?=$page->title?></h1> | |
<h3><?=$page->created?></h3> | |
<?=$page->body?> | |
<?=$modules->get('FacebookLike')->render();?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.'&layout='.$this->layout.'&show_faces='.$this->showFaces.'&width='.$this->width.'&action=like&font='.$this->font.'&colorscheme=light&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