Jump to content

Native Module Social Sharing not work


Recommended Posts

Hello,

I am writing to report that the module "social sharing" has some problems. When I click on one of the four keys to share the product on one of the social network nothing happens.
 

PS version 1.6.0.14
Module version 1.3.0 by PrestaShop

 

I have tried uninstalling and reinstalling and reset the module, but nothing has changed.

can someone help me?

 

Thank you.

Link to comment
Share on other sites

  • 2 months later...

Hi Nemo1

 

I have the same problem with the module but the error is different. Social Sharing module shows the buttoms in product page but when you click on them nothing happens. The error showed by the console is "Uncaught SyntaxError: Unexpected token ILLEGAL"

 

And the .tpl for the buttoms I think is correct. I show it at the end.

 

I've been looking for a solution for days and it seems like in every forums nobody says a solution.

 

I've uninstalled and reinstalled the module. I've try to click on the buttoms without the adblocker of the web browsers etc. 

 

Does anybody know how can I correct it?

 

Thanks in advance

 

<p class="socialsharing_product list-inline no-print">
{if $PS_SC_TWITTER}
<button type="button" class="btn btn-outline btn-twitter" onclick="socialsharing_twitter_click('{$product->name|addslashes} {$link->getProductLink($product)|addslashes}');">
<i class="fa fa-twitter"></i> Tweet
<!-- <img src="{$link->getMediaLink("`$module_dir`img/twitter.gif")}" alt="Tweet" /> -->
</button>
{/if}
{if $PS_SC_FACEBOOK}
<button type="button" class="btn btn-outline btn-facebook" onclick="socialsharing_facebook_click();">
<i class="fa fa-facebook"></i> Share
<!-- <img src="{$link->getMediaLink("`$module_dir`img/facebook.gif")}" alt="Facebook Like" /> -->
</button>
{/if}
{if $PS_SC_GOOGLE}
<button type="button" class="btn btn-outline btn-google-plus" onclick="socialsharing_google_click();">
<i class="fa fa-google-plus"></i> Google+
<!-- <img src="{$link->getMediaLink("`$module_dir`img/google.gif")}" alt="Google Plus" /> -->
</button>
{/if}
{if $PS_SC_PINTEREST}
<button type="button" class="btn btn-outline btn-pinterest" onclick="socialsharing_pinterest_click();">
<i class="fa fa-pinterest"></i> Pinterest
<!-- <img src="{$link->getMediaLink("`$module_dir`img/pinterest.gif")}" alt="Pinterest" /> -->
</button>
{/if}
</p>
Link to comment
Share on other sites

Hello, I solved it changing the socialsharing.js. My code had a different intro. This is the new one

 

/**
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

function socialsharing_twitter_click(message)
{
    if (typeof message === 'undefined')
        message = encodeURIComponent(location.href);
    window.open('https://twitter.com/intent/tweet?text=' + message, 'sharertwt', 'toolbar=0,status=0,width=640,height=445');
}

function socialsharing_facebook_click(message)
{
    window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(location.href), 'sharer', 'toolbar=0,status=0,width=660,height=445');
}

function socialsharing_google_click(message)
{
    window.open('https://plus.google.com/share?url=' + encodeURIComponent(location.href), 'sharergplus', 'toolbar=0,status=0,width=660,height=445');
}

function socialsharing_pinterest_click(image_url)
{
    window.open('http://www.pinterest.com/pin/create/button/?media=' + encodeURIComponent(image_url) + '&url=' + encodeURIComponent(location.href), 'sharerpinterest', 'toolbar=0,status=0,width=660,height=445');
}

Link to comment
Share on other sites

  • 3 years later...

If you are using an old theme perhaps you should watch the "socialsharing.tpl" template too.

Prestashop changed the javascript functions so you need to copy the original code from the updated module.

  1. Remove the "onclick"
  2. add the class "social-sharing"
  3. add the "data-type" attribute

For example the code is from:

<button type="button" class="btn btn-outline btn-twitter" onclick="socialsharing_twitter_click('{$product->name|addslashes} {$link->getProductLink($product)|addslashes}');">

to:

<button type="button" class="btn btn-outline btn-twitter social-sharing" data-type="twitter">

Do this for all buttons.

Link to comment
Share on other sites

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...