MyBB Community Forums

Full Version: pull thread description up when sharing on fb?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use this code in a template for a fb share button

<a title="Facebook" 
href="http://www.facebook.com/share.php?u=http://www.website.com/showthread.php?tid={$thread['tid']}&title={$thread['subject']}"
 target="_blank"><img src="images/elegant/Facebook.png" alt="Facebook" 
/></a>

Now it fills in the title and the link, but how could i get it to display some of the first post? is this possible.
I would like to know this as well.
Bump as still needed
(2014-10-27, 08:29 PM)dmpops22 Wrote: [ -> ]I use this code in a template for a fb share button


<a title="Facebook" 
href="http://www.facebook.com/share.php?u=http://www.website.com/showthread.php?tid={$thread['tid']}&title={$thread['subject']}"
 target="_blank"><img src="images/elegant/Facebook.png" alt="Facebook" 
/></a>

Now it fills in the title and the link, but how could i get it to display some of the first post? is this possible.


This is a question for Facebook. With a little search, I found a page to help webmasters optimze pages for facebook. You need some way to generate the open graph meta tags in the header_include template with data that's unique for that tag.
(2014-10-29, 06:25 PM)laie_techie Wrote: [ -> ]
(2014-10-27, 08:29 PM)dmpops22 Wrote: [ -> ]I use this code in a template for a fb share button




<a title="Facebook" 
href="http://www.facebook.com/share.php?u=http://www.website.com/showthread.php?tid={$thread['tid']}&title={$thread['subject']}"
 target="_blank"><img src="images/elegant/Facebook.png" alt="Facebook" 
/></a>

Now it fills in the title and the link, but how could i get it to display some of the first post? is this possible.


This is a question for Facebook. With a little search, I found a page to help webmasters optimze pages for facebook. You need some way to generate the open graph meta tags in the header_include template with data that's unique for that tag.

Oh im aware of that i googled it hard to look, but im not sure how to pull up the description of a thread/first post on mybb, i can add a custom static non changing description, but for how exactly to pull the first post description is beyond me.

But for sharing of threads i would like to to change to contents of the first post.
You'll need to create (or find) a plugin:
1. Add a variable (I suggest $fb_header_include) to your header_include template.
2. Register a hook for showthread_start. The hooked function should populate $fb_header_include with Open Graph meta tags based on the values located in $thread (BTW, $thread['tid'] gives you the thread id).
3. When you have that working, you may want to register other hooks to cover over parts of the forum (such as the index page and forum display).