vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Show Thread Enhancements - Facebook / Open Graph (og:description) / (og:title) tag fixes for VB 4.1.10+ by BOP5 (https://vborg.vbsupport.ru/showthread.php?t=305162)

sv1cec 12-07-2013 05:10 PM

OK, I solved my Connect button issue and I made a small change to this hack, so that it covers all pages of the site. Here is the code I used.

Code:

if (THIS_SCRIPT == 'showthread')
{
  global $thread;
  $og_array['og:description'] = $thread['meta_description'];
  $og_array['og:title'] = $thread['title'];
}
else
{
  $og_array['og:title'] = "Enter the title of your site here";
}


BirdOPrey5 12-07-2013 06:40 PM

Quote:

Originally Posted by sv1cec (Post 2466640)
OK, I solved my Connect button issue and I made a small change to this hack, so that it covers all pages of the site. Here is the code I used.

Code:

if (THIS_SCRIPT == 'showthread')
{
  global $thread;
  $og_array['og:description'] = $thread['meta_description'];
  $og_array['og:title'] = $thread['title'];
}
else
{
  $og_array['og:title'] = "Enter the title of your site here";
}


That may be OK for people with just the vB 4.x forum, but I would not recommend it for people with the VB 4.x Suite as Blog and CMS articles will then lose their custom titles.

sv1cec 12-10-2013 08:12 AM

Obviously Joe is right about this (not using my code shown above, if you are using vBSuite.

However, being the stubborn person I am, I keep trying to figure out how to fill the og: array with the proper values.

So far, here is what I have come up with:

Code:

if (THIS_SCRIPT == 'showthread')
{
  global $thread;
  $og_array['og:description'] = $thread['meta_description'];
  $og_array['og:title'] = $thread['title'];
}
if (THIS_SCRIPT == 'entry' OR THIS_SCRIPT == 'blog')
{
  global $blog, $bloginfo;
  if ($blog['message'] != "")
  {
          $og_array['og:description'] = $blog['message'];
  }
  else
  {
        $og_array['og:description'] = "BBB";
  }
  $og_array['og:title'] = $bloginfo['title'];
}

So far, the og:title parameter is filled by the $bloginfo['title'] variable and that's a good thing. However, the og:description doesn't seem to get updated from $blog['message'].

I am using the blog_show_entry template as a guide line, and in there, it appears that the proper variable to use is indeed $blog['message'], but that is obviously not set, when the script above loads?? I do not understand.

Interestingly enough, the vbcms articles automatically get the proper og:description (the article text itself, but their title comprises of the site title and then the title of the article. I wonder if there is a way to use only the article's title.

ZUCCO 12-11-2013 06:29 PM

Looks cool, thanks

BirdOPrey5 12-11-2013 08:46 PM

sv1cec, and everyone-

I went ahead and upgraded this to version 1.2.0- it now adds full support for a blog description (limited to 300 characters if need be) and a better blog title.

The blog title is now formatted "blog title Posted By username"

And the "Posted By" uses the default vBulletin phrase so it will translate to whatever language your forum uses.

I did a lot of research on using it for Articles- it does not appear worth the effort- the way Articles are coded you simply can't get the title or preview text where the facebook open graph text is built. It could be done but would likely need additional plugins- but besides that Articles have a meta description option that you can fill in yourself and if available vBulletin does use the meta description as the open graph description on Article pages.

Spangle 12-14-2013 12:01 PM

I've got a 4.2.2 forum, and have just installed this, but it doesn't seem to be working, I've gone from the Thread title to the URL and from the generic meta description to nothing !

https://www.facebook.com/groups/footballounge/

BirdOPrey5 12-14-2013 02:12 PM

Quote:

Originally Posted by Spangle (Post 2468208)
I've got a 4.2.2 forum, and have just installed this, but it doesn't seem to be working, I've gone from the Thread title to the URL and from the generic meta description to nothing !

https://www.facebook.com/groups/footballounge/

The Facebook Debugger says the problem is your Facebook Image-

https://developers.facebook.com/tool...Carroll-regret

The image must be a full absolute URL, with the http at the front, not the relative path you have.

Spangle 12-14-2013 02:39 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2468218)
The Facebook Debugger says the problem is your Facebook Image-

https://developers.facebook.com/tool...Carroll-regret

The image must be a full absolute URL, with the http at the front, not the relative path you have.

Thats fixed it thanks !

Dilldogs 12-14-2013 02:39 PM

I am using vb 4.1.7 is there anyway you could get this to work for 4.0 and higher?

BirdOPrey5 12-14-2013 04:59 PM

Quote:

Originally Posted by Dilldogs (Post 2468228)
I am using vb 4.1.7 is there anyway you could get this to work for 4.0 and higher?

The problem is the hook this runs on does not exist in the code until 4.1.1.0.

If You want I suppose you can add the hook manually.

You'll need to edit 2 things.

First, edit your includes/functions_facebook.php file

Find the line:
Code:

return $og_array;
And directly ABOVE that add the line:
Code:

($hook = vBulletinHook::fetch_hook('fb_opengraph_array')) ? eval($hook) : false;
Then save and re-upload the file. I suggest you rename the original on your server so you have a backup before you upload the changed file. Rename if to something like functions_facebook_old.php (make sure you keep the .php extension)

Then edit this product's .xml file before you import it to product manager.

Find:
Code:

4.1.10
and change it to

Code:

4.0.0
and save the file and import it.

It *should* work.

Also note- you'll never be able to edit the plugin in plugin manager because your vBulletin version doesn't know the hook exists and won't let you re-save the plugin in the correct hook. Not that you should have any reason to edit the plugin, just keep it in mind.


All times are GMT. The time now is 06:53 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01173 seconds
  • Memory Usage 1,750KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete