blank
search_image
header-right

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.

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"></script>');
        // Digg
        $return .= '<script src="http://widgets.digg.com/buttons.js" type="text/javascript"></script>';
        $return .= $this->_wrap('<a class="DiggThisButton DiggCompact"></a>');
        $return .= $this->_wrap(
        <<<DELIC
<a href="http://delicious.com/save"
    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;">
    <img src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious" BORDER="0"/>
    Delicious
    </a>
DELIC
        );
        $return .= '</div>';
        return $return;
    }
    
    private function _wrap($text)
    {
        return '<span class="socialMediaElement">' . $text . '</span>';
    }
}

And on your view script

<div><?php echo $this->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

.socialMedia {
    width: 80%;
    margin: auto;
    text-align: center;
    margin-bottom: 10px;
    padding: 10px;
    height: 20px;
}

.socialMediaElement {
    float: left;
    padding-left: 20px;
}

Done

Comments on Zend Framework social media view helper

Jorik
Posted on 8/30/10 6:03 AM
very convenient!!!
You can read all the network from an array
 
Post a comment

 
Prove yer human; set the bits for 27



Home | About Me | About Zend | Links | My Videos | Community Webinars | Office HTML Cleaner
© 2010