Frank Vèssia Posted July 19, 2011 Share Posted July 19, 2011 I modified a well done module (thanks to almonk) that shows up facebook like button to obtain a more complete set of social buttons that i always use for my sites. This module can shows facebook, twitter and google+ buttons. Example: <? $like = $modules->get('SocialBlock'); //$like->fbEnabled ='false'; to hidden a button (fbEnabled|twEnabled|gEnabled) $like->fbwidth = '110'; $like->fburl = 'http://www.yoursite.com/page/'; $like->twtext = $page->title; $like->twvia = 'yoursitename'; $like->twlang = 'italian'; $like->gsize = 'small'; echo $like->render(); ?> Module code: <?php class SocialBlock extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Social Networks buttons', 'version' => 006, 'summary' => 'Display Facebook/Twitter/Google+ buttons on your Processwire site.', 'href' => 'http://www.complementaryart.com', 'singular' => false, 'autoload' => false, ); } public function init() { $this->set('fbEnabled', 'true'); $this->set('fburl', ''); $this->set('fblayout', 'button_count'); $this->set('fbshowFaces', 'false'); $this->set('fbcolorscheme', 'light'); $this->set('fbwidth', '150'); $this->set('fbheight', '20'); $this->set('fbfont', 'Arial'); $this->set('twEnabled', 'true'); $this->set('twurl', ''); $this->set('twtext', ''); $this->set('twcount', 'horizontal'); $this->set('twvia', ''); $this->set('twlang', 'english'); $this->set('gEnabled', 'true'); $this->set('gsize', 'medium'); $this->set('gcount', 'true'); } public function ___render() { $social = ""; if ($this->fbEnabled){ if(!$this->fburl) $this->fburl = $page->url; // Build the iframe $social .= '<iframe src="http://www.facebook.com/plugins/like.php?href='.$this->fburl.'&layout='.$this->fblayout.'&show_faces='.$this->fbshowFaces.'&width='.$this->fbwidth.'&action=like&font='.$this->fbfont.'&colorscheme='.$this->fbcolorscheme.'&height='.$this->fbheight.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$this->fbwidth.'px; height:'.$this->fbheight.'px;" allowtransparency="true"></iframe>'; } if ($this->twEnabled){ if(!$this->twurl) $this->twurl = $page->url; $social .= '<a href="http://twitter.com/share" class="twitter-share-button" data-url="'.$this->twurl.'" data-text="'.$this->twtext.'" data-count="'.$this->twcount.'" data-via="'.$this->twvia.'" data-lang="'.$this->twlang.'">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>'; } if ($this->gEnabled){ $social .= '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="'.$this->gsize.'" count="'.$this->gcount.'"></g:plusone>'; } return $social; } } SocialBlock.module Link to comment Share on other sites More sharing options...
Adam Kiss Posted July 20, 2011 Share Posted July 20, 2011 Nice! Link to comment Share on other sites More sharing options...
ryan Posted July 20, 2011 Share Posted July 20, 2011 Looks good, thanks for posting! Link to comment Share on other sites More sharing options...
onjegolders Posted July 26, 2012 Share Posted July 26, 2012 Thanks Sevarf for this module! However, when I use your code above in my site, only the Twitter icon shows up. Any idea why this could be? Cheers. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted July 27, 2012 Author Share Posted July 27, 2012 @onjergolders: this module is old and it needs an update, some things changed in social websites codes...I'll do it very soon. Link to comment Share on other sites More sharing options...
onjegolders Posted August 9, 2012 Share Posted August 9, 2012 @onjergolders: this module is old and it needs an update, some things changed in social websites codes...I'll do it very soon. Thanks buddy. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now