1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Open Graph Implementation

Discussion in 'Resolved Bug Reports' started by digitalpoint, Feb 13, 2013.

  1. digitalpoint

    digitalpoint Well-Known Member

    A couple issues here...

    The main forum page is tagged in Open Graph as an "article", rather than a "website". This makes it so when someone likes your main page, their Facebook feed shows they liked an article. This came to my attention when I liked my site and my mom calls me up to tell me she tried to read the article I liked, but it just took me to my website. :)


    Member profiles are also tagged as "article" instead of "profile". In addition, there's also some extra profile tags that can be used in Open Graph... This is how I changed it in my member_view template as an example:

    <xen:container var="$head.openGraph"><xen:include template="open_graph_meta">
    <xen:set var="$url">{xen:link 'canonical:members', $user}</xen:set>
    <xen:set var="$title">{$user.username}</xen:set>
    <xen:set var="$type">profile</xen:set>
    <xen:set var="$extra"><meta property="profile:username" content="{$user.username}" />
    <xen:if is="{$user.gender}"><meta property="profile:gender" content="{$user.gender}" /></xen:if></xen:set>
    <xen:set var="$avatar">{xen:helper avatar, $user, 'm', '', 'true'}</xen:set>
    /kick TinyMCE and tabs

    You could do other things like birthdate and stuff, but I didn't care enough to add them. :)

    The open_graph_meta template was changed to use $type and $extra to feed in extra secondary fields (like profiles).

    XenForo only puts Open Graph data on pages that you can embed the Facebook Like button, but it probably wouldn't be a bad idea to use Open Graph on forum display pages as well... it's a fairly common page to like (even without a FB button).
    erich37, 3rd AnGle and Chris D like this.
  2. Digital Doctor

    Digital Doctor Well-Known Member

    Thanks Mrs. Digitalpoint, ur da bestist mom evah.
  3. Mike

    Mike XenForo Developer Staff Member

    Adjusted for the next release. :)
  4. Iversia

    Iversia Well-Known Member

    I didn't want to create a new thread for this (as all new Xenforo installations won't experience the issue), but it's worth noting that some people may get a "Cannot change og_type" error through Facebook's debugger with this fix, due to the incorrect og:type being used in the first place.

    The Forum Heroes likes this.
  5. The Forum Heroes

    The Forum Heroes Well-Known Member

    Confirmed, though I never reported it either
  6. 0xym0r0n

    0xym0r0n Well-Known Member

    Yeah I'm playing around with opengraph right now and it happened for me as well lol
  7. TheBigK

    TheBigK Well-Known Member

    I've been reading all the threads on Facebook OpenGraph and it looks like xF integrates it all here. I'm still having issues with Facebook picking up user avatar instead of the images in posts when someone clicks on 'Like' or 'Share' button on.

    Is there any easy way to fix this up?

Share This Page