Topic-icon JFBC issue with Easyblog 5.1 AMP pages

Active Subscriptions:

None
9 years 1 month ago #61514 by espkri
The new EasyBlog 5.1 version which was released a few days ago added support for Google AMP pages, but it seems like the jfbc (skd.js) javascript is loaded:
www.altonline.no/magasin/dette-er-reglen...nnscooter?format=amp

Uncaught ReferenceError: jfbc is not defined
at window.fbAsyncInit (dette-er-reglene-for-kjoring-av-vannscooter?format=amp:167)
at v.__wrapper (sdk.js:95)
at sdk.js:139

Is there any ways to avoid this behaviour?
The topic has been locked.
Support Specialist
9 years 1 month ago #61523 by alzander
We'd have to investigate a bit further on how to detect an AMP page that EasyBlog is creating vs a normal HTML page. I don't have a good answer for you now as we'll need to investigate this. I just looked quickly for documentation on their site

It may be as simple as reordering any EasyBlog system plugins to happen after JFBConnect, which may properly detect and strip the Javascript we insert into the page. Feel free to test that and let us know how it goes.

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

None
9 years 1 month ago #61527 by espkri
Hi.

I tried to reorder the plugins, but issue are still present. Only workaround is to disable the JFBC system plugin.
The topic has been locked.
Active Subscriptions:

None
9 years 1 month ago #61534 by skyfranky
I am also having issue after upraded easyblog to 5.1 ver.

at easyblog page, login button no longer works, and have below error:
www.screencast.com/t/JPOP2GzD8
The topic has been locked.
Active Subscriptions:

None
9 years 1 month ago #61549 by espkri
Hi.

Any updates on this issue? Let me know if you think this is a issue which is needed to be fixed by the Stackideas team.
The topic has been locked.
Support Specialist
9 years 1 month ago #61554 by alzander
We're still looking into what would be an appropriate solution. AMP pages are designed to not allow Javascript to run, which our Facebook integration heavily relies on Javascript using both the Facebook library and our own code.

There are ways to get around the authentication portion if you're looking to have a Facebook login button on your AMP pages.. you'd just need to hardcode your own login buttons that point to each of the social networks you want to offer on those pages.

For the Facebook Javascript library inclusion, we need to do more investigation on how to detect if the page is an AMP based page and prevent those libraries from being loaded. That's something I would think StackIdeas would be doing since it seems like other javascript code is being removed, but I can't be certain.

Bottom line though, are you having any functional issues on the AMP based pages or is the console error just causing annoyance? Any insight into the functionality issues you're experiencing will help us know where to focus our attention for a fix.

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

None
9 years 1 month ago #61584 by espkri
Sorry for delayed feedback. I have asked Stackideas to look into this issue too. It´s not only a console error causing annoyance, but Google won´t display AMP pages as long there is 3rd party javascript running. I´ll update you when i get a response from Stackideas.
The topic has been locked.
Active Subscriptions:

None
9 years 1 month ago #61586 by espkri
The advice from the stackideas team was to add this line to the plugin/module:
<?php if (JFactory::getDocument()->getType() != 'html') { return; } ?>

I added it to the contruct method, and it seems like working, but i don´t know if this is the recommended way to do it.
    function __construct(& $subject, $config)
    {
        [b]if (JFactory::getDocument()->getType() != 'html') { return; }[/b]
        $factoryFile = JPATH_ROOT . '/components/com_jfbconnect/libraries/factory.php';
        if (!JFile::exists($factoryFile))
        {
            JFactory::getApplication()->enqueueMessage("File missing: " . $factoryFile . "<br/>Please re-install JFBConnect or disable the JFBCSystem Plugin", 'error');
            return; // Don't finish loading this plugin to prevent other errors
        }
        require_once($factoryFile);
        JFBCFactory::initializeJoomla();

        parent::__construct($subject, $config);

        $scTagArray = array('SCPinterest');
        foreach(JFBCFactory::getAllProviders() as $provider)
            $scTagArray[] = 'SC'.$provider->name;
        $this->scTags = implode('|', $scTagArray);
    }
The topic has been locked.
Support Specialist
9 years 1 month ago #61592 by alzander
The constructor isn't the right place for that as it may be overly aggressive and disable some features you wouldn't expect..

We already do similar checks to that in other areas of the system plugin. I think the main area you'd want to do it properly would be in the onAfterRender method. Right now, that looks like:
public function onAfterRender()
    {
        if (!JFactory::getApplication()->isAdmin())
Update that to:
public function onAfterRender()
    {
        if (!JFactory::getApplication()->isAdmin() && JFactory::getDocument()->getType() == 'html')
The same line you want to copy is about 8 lines up in the file, so it should be easy to check and make sure you got it right.

Please test and let us know how that goes. We'll test as well to make sure it doesn't cause any other unforeseen issues and likely get it included in the next release.

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

None
9 years 1 month ago #61596 by espkri
Thanks Alex. Added the check to the onAfterRender method, and it seems like it´s working :)
The topic has been locked.