Jump to content

How to add google plus button to "social block"


Antakarana

Recommended Posts

Hi everybody!

 

As you know on prestashop instalation there's a module called "social block" wich add socialnetwork links on footer:

 

- twitter

- Facebook

- RSS

 

I also would like to add a google+ link and maybe in a near future add some new social network links.

 

To do that I've just tried to edit the php and tp files placed at the social blok folder adding the code for google plus for example:

 

At the blocksocial.css file original code was:

 

#social_block {padding:15px 10px;}
#social_block li {padding-left:22px !important;}
#social_block li.facebook {background:url(img/sprite_pict_social_block.png) no-repeat 0 6px;}
#social_block li.twitter {background:url(img/sprite_pict_social_block.png) no-repeat 0 -26px;}
#social_block li.rss {background:url(img/sprite_pict_social_block.png) no-repeat 0 -56px;}

 

So i add this bottom line:

#social_block li.googleplus {background:url(img/sprite_pict_social_block.png) no-repeat 0 -56px;}

 

 

At the socialblock.php file i have this original code:

 

   public function install()
   {
       return (parent::install() AND Configuration::updateValue('blocksocial_facebook', '') && Configuration::updateValue('blocksocial_twitter', '') && Configuration::updateValue('blocksocial_rss', '') && $this->registerHook('displayHeader') && $this->registerHook('displayFooter'));
   }

   public function uninstall()
   {
       //Delete configuration            
       return (Configuration::deleteByName('blocksocial_facebook') AND Configuration::deleteByName('blocksocial_twitter') AND Configuration::deleteByName('blocksocial_rss') AND parent::uninstall());
   }

   public function getContent()
   {
       // If we try to update the settings
       $output = '';
       if (isset($_POST['submitModule']))
       {    
           Configuration::updateValue('blocksocial_facebook', (($_POST['facebook_url'] != '') ? $_POST['facebook_url']: ''));
           Configuration::updateValue('blocksocial_twitter', (($_POST['twitter_url'] != '') ? $_POST['twitter_url']: ''));        
           Configuration::updateValue('blocksocial_rss', (($_POST['rss_url'] != '') ? $_POST['rss_url']: ''));                
           $output = '<div class="conf confirm">'.$this->l('Configuration updated').'</div>';
       }

       return '
       <h2>'.$this->displayName.'</h2>
       '.$output.'
       <form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
           <fieldset class="width2">                
               <label for="facebook_url">'.$this->l('Facebook URL: ').'</label>
               <input type="text" id="facebook_url" name="facebook_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_facebook') != "") ? Configuration::get('blocksocial_facebook') : "").'" />
               <div class="clear"> </div>        
               <label for="twitter_url">'.$this->l('Twitter URL: ').'</label>
               <input type="text" id="twitter_url" name="twitter_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_twitter') != "") ? Configuration::get('blocksocial_twitter') : "").'" />
               <div class="clear"> </div>        
               <label for="rss_url">'.$this->l('RSS URL: ').'</label>
               <input type="text" id="rss_url" name="rss_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_rss') != "") ? Configuration::get('blocksocial_rss') : "").'" />
               <div class="clear"> </div>                        
               <br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
           </fieldset>
       </form>';
   }

   public function hookDisplayHeader()
   {
       $this->context->controller->addCSS(($this->_path).'blocksocial.css', 'all');
   }

   public function hookDisplayFooter()
   {
       global $smarty;

       $smarty->assign(array(
           'facebook_url' => Configuration::get('blocksocial_facebook'),
           'twitter_url' => Configuration::get('blocksocial_twitter'),
           'rss_url' => Configuration::get('blocksocial_rss')

 

Then I've added this new one:

 

   public function install()
   {
       return (parent::install() AND Configuration::updateValue('blocksocial_facebook', '') && Configuration::updateValue('blocksocial_twitter', '') && Configuration::updateValue('blocksocial_rss', '') && Configuration::updateValue('blocksocial_googleplus', '') && $this->registerHook('displayHeader') && $this->registerHook('displayFooter'));
   }

   public function uninstall()
   {
       //Delete configuration            
       return (Configuration::deleteByName('blocksocial_facebook') AND Configuration::deleteByName('blocksocial_twitter') AND Configuration::deleteByName('blocksocial_rss') AND Configuration::deleteByName('blocksocial_googleplus') AND parent::uninstall());
   }

   public function getContent()
   {
       // If we try to update the settings
       $output = '';
       if (isset($_POST['submitModule']))
       {    
           Configuration::updateValue('blocksocial_facebook', (($_POST['facebook_url'] != '') ? $_POST['facebook_url']: ''));
           Configuration::updateValue('blocksocial_twitter', (($_POST['twitter_url'] != '') ? $_POST['twitter_url']: ''));        
           Configuration::updateValue('blocksocial_rss', (($_POST['rss_url'] != '') ? $_POST['rss_url']: ''));
           Configuration::updateValue('blocksocial_googleplus', (($_POST['googleplus_url'] != '') ? $_POST['googleplus_url']: ''));                
           $output = '<div class="conf confirm">'.$this->l('Configuration updated').'</div>';
       }

       return '
       <h2>'.$this->displayName.'</h2>
       '.$output.'
       <form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
           <fieldset class="width2">                
               <label for="facebook_url">'.$this->l('Facebook URL: ').'</label>
               <input type="text" id="facebook_url" name="facebook_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_facebook') != "") ? Configuration::get('blocksocial_facebook') : "").'" />
               <div class="clear"> </div>        
               <label for="twitter_url">'.$this->l('Twitter URL: ').'</label>
               <input type="text" id="twitter_url" name="twitter_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_twitter') != "") ? Configuration::get('blocksocial_twitter') : "").'" />
               <div class="clear"> </div>        
               <label for="rss_url">'.$this->l('RSS URL: ').'</label>
               <input type="text" id="rss_url" name="rss_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_rss') != "") ? Configuration::get('blocksocial_rss') : "").'" />
               <div class="clear"> </div>
               <label for="googleplus_url">'.$this->l('Google+ URL: ').'</label>
               <input type="text" id="googleplus_url" name="googleplus_url" value="'.Tools::safeOutput((Configuration::get('blocksocial_googleplus') != "") ? Configuration::get('blocksocial_googleplus') : "").'" />
               <div class="clear"> </div>                    
               <br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
           </fieldset>
       </form>';
   }

   public function hookDisplayHeader()
   {
       $this->context->controller->addCSS(($this->_path).'blocksocial.css', 'all');
   }

   public function hookDisplayFooter()
   {
       global $smarty;

       $smarty->assign(array(
           'facebook_url' => Configuration::get('blocksocial_facebook'),
           'twitter_url' => Configuration::get('blocksocial_twitter'),
           'rss_url' => Configuration::get('blocksocial_rss')
           'googleplus_url' => Configuration::get('blocksocial_googleplus')

 

And so on with all the files wich make reference to the different social networks...

 

Then I rewrite the original files with the edited ones, but then my shop didn't load! Fortunately I've made a backup of the original files so I could easyly restore them...

 

Please, could anybody help me to know what I'm doing wrong?

 

Thanks!

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Hello Antakarana

 

Did you arrive to modify your blocksocial module? To answer your question, yes you made a mistake, you

 

miss a coma after the line

'rss_url' => Configuration::get('blocksocial_rss')

 

You need to add googleplus in the file: ...\modules\blocksocial\blocksocial.tpl

 

I did this but there is no new icone. Maybe I had to make a special config somewhere? Or is it related with the

 

cache?

 

Can anyone help?

Edited by yaovi.ametepe (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...