On all of the links on the site now I’ve added a social media thingy. I didn’t want one of those social media toolbars that was so freaking busy so-as to make it useless or annoying. So I did a really quick Zend Framework view helper that you can easily add to your site for individual pages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | class Zend_View_Helper_SocialMedia extends Zend_View_Helper_Abstract { public function socialMedia() { $return = ' <div class="socialMedia">'; // StumbleUpon $return .= $this->_wrap('<script src="http://www.stumbleupon.com/hostedbadge.php?s=1"><!--mce:0--></script>'); // Digg $return .= '<script src="http://widgets.digg.com/buttons.js" type="text/javascript"><!--mce:1--></script>'; $return .= $this->_wrap('<a class="DiggThisButton DiggCompact"></a>'); $return .= $this->_wrap( <<<a onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;" href="http://delicious.com/save"> <img src="http://static.delicious.com/img/delicious.small.gif" border="0" alt="Delicious" width="10" height="10" /> Delicious </a> DELIC ); $return .= '</div> '; return $return; } private function _wrap($text) { return '<span class="socialMediaElement">' . $text . '</span>'; } } |
And on your view script
1 | <div>socialMedia(); ?></div> |
You also need to define the CSS classes for the social media DIV container as a whole as well as the individual elements. Mine is this
1 2 3 4 5 6 7 8 9 10 11 12 13 | .socialMedia { width: 80%; margin: auto; text-align: center; margin-bottom: 10px; padding: 10px; height: 20px; } .socialMediaElement { float: left; padding-left: 20px; } |
Done
Comments
Jorik
very convenient!!!
You can read all the network from an array