Topic-icon Error when previewing EasyBlog Post (Open Graph Plugin Issue)

Active Subscriptions:

None
Hello

When you have created an EasyBlog post in frontend, in EasyBlog Composer you can choose to "Preview Post". If you do so you get:
File Attachment:


This is because JFBConnect Open Graph plugin is expecting to find the id of the blog post in the URL, whereas preview page URL looks like:
index.php?option=com_easyblog&Itemid=781&lang=fr&layout=preview&uid=113.253&view=entry

StackIdeas has suggested some changes in easyblog.php file of the plugin, in the findObjectType() function:
protected function findObjectType($queryVars)
    {
        // Setup Object type for page
        $view = array_key_exists('view', $queryVars) ? $queryVars['view'] : '';

        // To determine if we are viewing normal entry layout or preview layout
        $layout = array_key_exists('layout', $queryVars) ? $queryVars['layout'] : '';
        $object = null;

        if ($view == 'entry')
        {
            $this->loadEB();
            $blog = $this->getEBTable('Blog');

            $objectTypes = $this->getObjects('post');

            $blogId = $queryVars['id'];

            // If layout is preview, we need to get the proper blog id.
            // For preview layout, the id will be uid.
            if ($layout && $layout == 'preview') {
                $blogId = $queryVars['uid'];
            }

            // Alternately, we can use EB::post($blogId) to load the post.
            // The system will inteligently enough to determine this post is preview or normal post based on the provided id/uid.
            $post = EB::post($blogId);

            if ($post) {
                $catId = $post->category_id;
                $object = $this->getBestCategory($objectTypes, $catId);
            }

            // if ($blog->load($blogId))
            // {
            //     $catId = $blog->category_id;
            //     $object = $this->getBestCategory($objectTypes, $catId);
            // }
        }
        return $object;
    }
Can you please check this and see what needs to be done to fix the error? Don't hesitate to ask if you need more information, you can also have access to my dev site with EasyBlog and JFBConnect installed.

Regards
The topic has been locked.
Support Specialist
The code above looks to work for recent versions of EasyBlog. We'll need to do some testing with early releases to make sure it won't break compatibility with users who aren't on the latest.

The only change I'd make is to update this section:
$blogId = $queryVars['id']; 

            // If layout is preview, we need to get the proper blog id. 
            // For preview layout, the id will be uid. 
            if ($layout && $layout == 'preview') { 
                $blogId = $queryVars['uid']; 
            }
To:
// If layout is preview, we need to get the proper blog id.
            // For preview layout, the id will be uid.
            if ($layout && $layout == 'preview') {
                $blogId = $queryVars['uid'];
            }
            else
                $blogId = $queryVars['id'];
That will fix a possible PHP Warning from showing up in the front-end.

Please feel free to test and let us know how it goes. We are releasing JFBConnect v7.0.1 today, so this fix won't be in this release. I've added it to our to-do list for 7.0.2 though.

Thanks,
Alex
The topic has been locked.