Giter Site home page Giter Site logo

vbulletin-ogimagethreadfield's Introduction

Open Graph Image Threadfield

This product for vBulletin 3.8 adds support for saving and editing an Open Graph image meta tag for each thread. Four file edits in includes/functions.php are required to be able to use the data for the meta tag in the headinclude template.

Included are also instructions to use the preview text of the first post of the thread for an Open Graph description meta tag and an improved meta description tag since vBulletin uses a poorly constructed meta description tag by only using the thread title and current page number.

Product upload

First upload product-ogimagethreadfield.xml in the Products & Plugins section.

File edits

Find near line 1272:

$threadcache["$threadid"] = $vbulletin->db->query_first("
  SELECT IF(visible = 2, 1, 0) AS isdeleted,

Replace with:

$threadcache["$threadid"] = $vbulletin->db->query_first("
  SELECT IF(thread.visible = 2, 1, 0) AS isdeleted,

Find near line 1278:

. iif($vbulletin->options['threadvoted'] AND $vbulletin->userinfo['userid'], 'threadrate.vote,')
. iif($marking, 'threadread.readtime AS threadread, forumread.readtime AS forumread,') . "

Replace with:

. iif($vbulletin->options['threadvoted'] AND $vbulletin->userinfo['userid'], 'threadrate.vote,')
. iif($marking, 'threadread.readtime AS threadread, forumread.readtime AS forumread,')
. iif($vbulletin->options['threadpreview'] > 0 AND THIS_SCRIPT == 'showthread', 'post.pagetext AS preview, ') . "

Find near line 1293:

$tachyjoin
$hook_query_joins
WHERE thread.threadid = $threadid

Replace with:

" . iif($vbulletin->options['threadpreview'] > 0 AND THIS_SCRIPT == 'showthread', "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)") . "  
$tachyjoin
$hook_query_joins
WHERE thread.threadid = $threadid

Find near line 1307:

$thread = $threadcache["$threadid"];
if ($thread['prefixid'])
{

Replace with:

if($vbulletin->options['threadpreview'] > 0 AND THIS_SCRIPT == 'showthread') 
{ 
  $threadcache["$threadid"]['preview'] = strip_quotes($threadcache["$threadid"]['preview']);
  $threadcache["$threadid"]['preview'] = htmlspecialchars_uni(
    fetch_censored_text(
      fetch_trimmed_title(
        strip_bbcode($threadcache["$threadid"]['preview'], false, true),
        $vbulletin->options['threadpreview'])
      )
  );
}  

$thread = $threadcache["$threadid"];
if ($thread['prefixid'])
{

Template edits

Go to the headinclude template in any of your styles.

Use the following code to add the Open Graph image meta tag to thread pages.

<if condition="$show['threadinfo'] AND !empty($threadinfo[img])">
  <meta property="og:image" content="$threadinfo[img]">
</if>

Use the following code to add an Open Graph description meta tag to thread pages.

<if condition="$show['threadinfo']">
  <meta property="og:description" content="$threadinfo[preview]">
</if>

Use the following code to use thread specific data in the meta description tag

<if condition="$show['threadinfo']">
  <meta name="description" content="$threadinfo[preview]<if condition="$pagenumber > 1"> (<phrase 1="$pagenumber">$vbphrase[page_x]</phrase>)</if>">
</if>

Result

If done properly, your thread pages will produce HTML metadata like this:

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
  <meta charset="utf-8">
  <meta name="description" content="Lorem ipsum dolor sit amet, consectetur adipiscing elit">
  <meta property="og:description" content="Lorem ipsum dolor sit amet, consectetur adipiscing elit">
  <meta property="og:image" content="https://www.myvbulletinforum.com/attachment.php?attachmentid=1">
  ...

vbulletin-ogimagethreadfield's People

Contributors

nickbeen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.