Search code examples
phpzend-frameworkzend-db

Zend adding facebook like


how to add facebook like features in zend based application ? is the code will be placed in view or in helpers ?

facebook.app_id = "APPID"
facebook.app_secret = "SECRET"

thanks


Solution

  • the easiest way to add facebook like in zend is by adding the code in helpers, later can be called from the view.

    class Application_View_Helper_GetFacebookLikeBox extends Zend_View_Helper_Abstract
    {
    public function getFacebookLikeBox()
    {
        $config = Zend_Registry::get('config');
        $app_id = $config['facebook']['app_id'];
    
        return '<iframe
                    src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FEXAMPLE&amp;
                        width=250&amp;height=284&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;
                        stream=false&amp;header=false&amp;appId='.$app_id.'"
                    scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:284px;"
                    allowTransparency="true">
                </iframe>';
    }
    }
    

    then from view just call $this->getFacebookLike(); will render the facebook like button.