Topic-icon JFBCSocialShare Feature Request

Active Subscriptions:

None
Hi,

Currently I use built-in Jreviews social buttons for my sharing. The site has an SSL certificate and I force https for logged-in users. Jreviews has a setting that forces http on the social buttons even if the page is being viewed with https, avoiding "cannibalizing" social media juice over two URLs.

I love the JFBCSocialShare Module but can't use it because of the http/https doubles on the social buttons.

So here is a formal feature request to add an option to allow forcing of http.

Thanks for listening.
The topic has been locked.
Support Specialist
12 years 2 months ago #42407 by alzander
It's an excellent idea, and one we had toyed with earlier. There was a bug post on Facebook's developers area about the difference between http and https a while ago. They responded that they were going to fix the problem. They obviously haven't.

For now, to force one or the other for the automatic URLs we generate, there's 2 places you'd need to edit the code to force things to either http or https:
For modules and {JFBCxxx} tags
Edit /libaries/sourcecoast/utilities.php. Around line 209, you'll see:
if ($query)
            $href .= '?' . $query;

        return $href;
Update that to:
if ($query)
            $href .= '?' . $query;
        $href = str_replace("http://", "https://", $href);

        return $href;
That will make all links https. You can reverse the parameters for the other direction.

For the Content plugin social buttons
Edit /libraries/sourcecoast/articleContent.php. Around line 175, you'll see:
$url = rtrim($jUri->toString(array('scheme', 'host', 'port')), '/') . $url;
        return $url;
Update that to:
$url = rtrim($jUri->toString(array('scheme', 'host', 'port')), '/') . $url;
        $url = str_replace("http://", "https://", $url);
        return $url;
[/code]
I hope that helps get you going. I added this to our to-do list for JFBConnect 6.1 to add as an option to force one way or the other. We'd love to have your feedback in the meantime to make sure it works as expected.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 2 months ago #42479 by Ludwig von Mises
Thanks for that info. I'm still up in the air on this one, as I have found another issue with the module.

I can't have two on the same page. Why would I want two? Using responsive support classes, I need one visible only on large screens, floating. And I need a second one for smaller screens, fixed. If I have two of these modules published on the same page it doesn't load correctly. Only the HTML loads with no CSS or JS.
The topic has been locked.
Support Specialist
12 years 2 months ago #42490 by alzander
Can you point me to a URL where you have both published? We've never heard of the issue you mention before, but maybe we missed testing a specific configuration like you have setup.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 2 months ago #42497 by Ludwig von Mises
That was happening on an EasyBlog page, where I had the sliding module in the template sidebar and the fixed module in an EasyBlog theme custom position.

Since that blog is live and cannot be used for testing, I moved the two modules to a test page and it gives the following php error:

Fatal error: Cannot redeclare addPxToString() (previously declared in /home/user/public_html/modules/mod_jfbcsocialshare/mod_jfbcsocialshare.php:105) in /home/user/public_html/modules/mod_jfbcsocialshare/mod_jfbcsocialshare.php on line 110

For what it's worth, here's the broken page: coinvalues.com/test-page
The topic has been locked.
Support Specialist
12 years 2 months ago #42509 by alzander
Well that's embarrassing. There's an easy fix for that issue if you can edit the /modules/mod_jfbcsocialshare/mod_jfbcsocialshare.php file. Around line 105, you'll see:
function addPxToString($amount)
{
    if(strpos($amount, "px")===false)
        $amount .= "px";
    return $amount;
}
Update that like:
if (!function_exists('addPxToString')) {
   function addPxToString($amount)
   {
       if(strpos($amount, "px")===false)
           $amount .= "px";
       return $amount;
   }
}
The changes are the first line and the closing } in the last line. That will make sure the fatal error doesn't occur.

Hopefully, that will fix all the issues you're having, but if not, let us know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 2 months ago #42513 by Ludwig von Mises
I added your conditional and now the error is on line 57:

Fatal error: Call to undefined function addPxToString() in /home/user/public_html/modules/mod_jfbcsocialshare/mod_jfbcsocialshare.php on line 57

That line is:
$facebookHeight = addPxToString($facebookHeight);

and is followed by:
$facebookWidth = addPxToString($facebookWidth);
The topic has been locked.
Support Specialist
12 years 2 months ago #42555 by alzander
Sorry about that. We're fixing the issue in a different way for the next release, but our fix uses a lot more code.. and I didn't want to overwhelm you with changes.

To fix the error you're seeing now, please move the whole block of code that I had you add to the top of the mod_jfbcsocialshare.php file to line 11 (right under the defined('_JEXEC') .. line), like:
// no direct access
defined('_JEXEC') or die('Restricted access');

if (!function_exists('addPxToString'))
{
    function addPxToString($amount)
    {
        if (strpos($amount, "px") === false)
            $amount .= "px";
        return $amount;
    }
}

jimport('joomla.filesystem.file');
I've actually tested that code and it definitely works for us. I was able to instantiate 2 JFBCSocialShare modules and have both display properly (one was floating in the corner of the browser, the other was in a module position).

I hope that helps get you going,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 2 months ago #42570 by Ludwig von Mises
That fixed it.

Thanks!
The topic has been locked.
Support Specialist
12 years 2 months ago #42579 by alzander
Glad to hear that got you going. Again, sorry for the silly PHP error in that module. A similar fix will be in the next release, so you don't have to worry about that code change going forward.

Thanks,
Alex
The topic has been locked.