Velocd
08-16-2002, 10:00 PM
vB3 Similar Threads for 2.2.x
Clone version | by Velocd
This hack, as well all my other vB2 hacks, I no longer provide support for (being I run vB3 and it's too much hassel to debug vB2). When vB3 Release Candidate comes out, by request I might convert some of my hacks.
Install time: 6 minutes
File edits: 1 (showthread.php)
Template edits: 1 (showthread)
New templates: 2 (showthread_similarthreads, showthread_similarthreadbits)
What is it?
Basically this hack will check for other similar thread titles within the forum of the thread you are viewing, then it will display the most similar threads, based on a similar-priority setting you choose, at the bottom of that thread.
Why did I make it?
This hack instantly drew my attention when I first saw it at the Jupiter vB3 forums. I figured it couldn't be that bad to make, and why wait when it's such a simple feature to integrate as a standalone hack? So, I opened up my TextPad and started coding. ;)
Personally, I HIGHLY doubt the method and coding I used in my hack is at all similar to the one at Jupiter vB3, but it seems to work just as fine. Even on my small forum the results on some threads look good, while for a large forum such as vB.org the results would look 3x as better.
Features:
Displays everything that the vB3 similar threads does.
Also gives a description of the thread, only if you have the thread-description hack installed. (source: here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=38916&highlight=thread+descriptions))
Bugs?
Depending on the priority level you pick, some threads that you are "dead sure" to have a similar result might not show. You might have to toggle the priority level at first, to get it set just right. Other than this, it's fairly clean.
See a demo at this thread, scroll to bottom:
http://beta.vbulletin.com/vb3/showthread.php?threadid=990
Screenshots? Demo's?
See the next post for a screenshot. Want a demo? Visit the similar thread feature at the Jupiter vB3 forums :p
------------- Installation -------------
#1. In showthread.php, find:
if ($noshutdownfunc) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
} else {
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'";
}
if ($bbuserinfo[cookieuser]) {
vbsetcookie("bbthreadview[$threadid]",time(),0);
}
Above it place:
//////////////////////////////////////////////////
// vBulletin3 Similar Threads "clone" by Velocd //
//////////////////////////////////////////////////
//////////////////////////// CONFIGURE ////////////////////////////////
$description_option = 0; //1 = on, 0 = off. (use only if you have THREAD descriptions installed)
if($description_option){ $desc = ",description"; }
$limit = 4; //Set the limit to the maximum amount of results to display
$priority = 60; //KEY: [less accurate, more results <0 --- 25 ---- 50 ---- 75 --- 100> more accurate, less results]
$previewcharacters = 150; //Amount of characters shown in the preview
///////////////////////////////////////////////////////////////////////
$rthreads=$DB_site->query("SELECT threadid,title,postusername,replycount,lastpost,po stuserid,dateline$desc
FROM thread
WHERE forumid='$thread[forumid]'
ORDER BY dateline");
$validtitle = trim(strtolower($thread[title])," \t.");
$count = 0;
while ($rthread = $DB_site->fetch_array($rthreads)) {
$validthread = trim(strtolower($rthread[title])," \t.");
similar_text($validtitle, $validthread, &$similarity);
if($similarity > $priority){
$similar[title] = $rthread[title];
$similar[threadid] = $rthread[threadid];
$similar[postusername] = $rthread[postusername];
$similar[postuserid] = $rthread[postuserid];
$similar[replycount] = $rthread[replycount];
$similar[date] = vbdate($dateformat,$rthread[lastpost]);
$similar[description] = $rthread[description];
if (strlen($similar[description]) > 150) {
$similar[description] = substr($similar[description], 0, $previewcharacters) . "..."; } else {
$similar[description] = $similar[description];
}
if($similar[threadid] != $thread[threadid] && $count < $limit){
$count++;
eval("\$similarthreadbits .= \"".gettemplate("showthread_similarthreadbits")."\";"); }
}
}
if($count != 0){
eval("\$similarthreads .= \"".gettemplate("showthread_similarthreads")."\";"); }
////////////////////////////
// End Similar Threads /////
////////////////////////////
Now look at this block of code from above:
//////////////////////////// CONFIGURE ////////////////////////////////
$description_option = 0; //1 = on, 0 = off. (use only if you have THREAD descriptions installed)
if($description_option){ $desc = ",description"; }
$limit = 4; //Set the limit to the maximum amount of results to display
$priority = 60; //KEY: [less accurate, more results <0 --- 25 ---- 50 ---- 75 --- 100> more accurate, less results]
$previewcharacters = 150; //Amount of characters shown in the preview
///////////////////////////////////////////////////////////////////////
As detailed, those variables change how this hack works. The main thing you need to notice is $priority, which at default is set at 60, which I've found on my forums to be good. As said in the KEY in comments, a higher priority will get you more accurate similar threads, but less results. Ofcourse, a high priority is ideal for a large forum. Lower priority vice versa.
#2. Create a new template called
showthread_similarthreads, and place inside:
<table cellpadding="{_tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{_tablebordercolor}" {_tableouterextra} width="{_contenttablewidth}" align="center">
<tr><td>
<table cellpadding="4" cellspacing="{_tableinnerborderwidth}" border="0" {_tableinnerextra} width="100%">
<tr>
<td bgcolor="{_tableheadbgcolor}" width="{_tablewidth}" colspan="4" align="center">
<normalfont color="{_tableheadtextcolor}">
<b>Similar Threads</b></normalfont></td>
</tr>
<tr align="center" bgcolor="{_categorybackcolor}" background="https://vborg.vbsupport.ru/images/catagory_backing.gif">
<td align="center" nowrap><span><smallfont><b>Thread</b></smallfont></span></td>
<td nowrap><span><b><smallfont>Thread Starter</smallfont></b></span></td>
<td nowrap><span><smallfont><b>Replies</b></smallfont></span></td>
<td nowrap><span><smallfont><b>Last Post</b></smallfont></span></td>
</tr>
$similarthreadbits
</table>
</td></tr></table>
<br>
In the code above, take out all the underscores (ie. _) out of the replacement variables, such as {_tablewidth}, or else they will not work.
#3. Create a new template called showthread_similarthreadbits, and place inside:
<tr align="center">
<td width="60%" align="left" bgcolor="{_firstaltcolor}"><normalfont>
<a href="showthread.php?s=$session[sessionhash]&forumid=$thread[forumid]&threadid=$similar[threadid]"
title="$similar[description]">$similar[title]
</a></normalfont></td>
<td width="20%" bgcolor="{_secondaltcolor}" nowrap="nowrap"><normalfont>
<a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$similar[postuserid]">$similar[postusername]
</a></normalfont></td>
<td bgcolor="{_firstaltcolor}"><normalfont>$similar[replycount]</normalfont></td>
<td bgcolor="{_secondaltcolor}" width="20%"><normalfont>$similar[date]</normalfont>
</td>
</tr>
In the code above, take out all the underscores (ie. _) out of the replacement variables, such as {_secondaltcolor}, or else the colors wont show.
#4. In the template showthread, find:
<!-- thread options links -->
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#0A293E" align="center"><tr><td>
On the line above it place:
$similarthreads
------------- End -------------
That's it! Pretty easy and quick to install, which is the nicest part about it. :)
If you use this hack remember, please click install! Without it, you might have had to wait till vB3 ;)
Clone version | by Velocd
This hack, as well all my other vB2 hacks, I no longer provide support for (being I run vB3 and it's too much hassel to debug vB2). When vB3 Release Candidate comes out, by request I might convert some of my hacks.
Install time: 6 minutes
File edits: 1 (showthread.php)
Template edits: 1 (showthread)
New templates: 2 (showthread_similarthreads, showthread_similarthreadbits)
What is it?
Basically this hack will check for other similar thread titles within the forum of the thread you are viewing, then it will display the most similar threads, based on a similar-priority setting you choose, at the bottom of that thread.
Why did I make it?
This hack instantly drew my attention when I first saw it at the Jupiter vB3 forums. I figured it couldn't be that bad to make, and why wait when it's such a simple feature to integrate as a standalone hack? So, I opened up my TextPad and started coding. ;)
Personally, I HIGHLY doubt the method and coding I used in my hack is at all similar to the one at Jupiter vB3, but it seems to work just as fine. Even on my small forum the results on some threads look good, while for a large forum such as vB.org the results would look 3x as better.
Features:
Displays everything that the vB3 similar threads does.
Also gives a description of the thread, only if you have the thread-description hack installed. (source: here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=38916&highlight=thread+descriptions))
Bugs?
Depending on the priority level you pick, some threads that you are "dead sure" to have a similar result might not show. You might have to toggle the priority level at first, to get it set just right. Other than this, it's fairly clean.
See a demo at this thread, scroll to bottom:
http://beta.vbulletin.com/vb3/showthread.php?threadid=990
Screenshots? Demo's?
See the next post for a screenshot. Want a demo? Visit the similar thread feature at the Jupiter vB3 forums :p
------------- Installation -------------
#1. In showthread.php, find:
if ($noshutdownfunc) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
} else {
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'";
}
if ($bbuserinfo[cookieuser]) {
vbsetcookie("bbthreadview[$threadid]",time(),0);
}
Above it place:
//////////////////////////////////////////////////
// vBulletin3 Similar Threads "clone" by Velocd //
//////////////////////////////////////////////////
//////////////////////////// CONFIGURE ////////////////////////////////
$description_option = 0; //1 = on, 0 = off. (use only if you have THREAD descriptions installed)
if($description_option){ $desc = ",description"; }
$limit = 4; //Set the limit to the maximum amount of results to display
$priority = 60; //KEY: [less accurate, more results <0 --- 25 ---- 50 ---- 75 --- 100> more accurate, less results]
$previewcharacters = 150; //Amount of characters shown in the preview
///////////////////////////////////////////////////////////////////////
$rthreads=$DB_site->query("SELECT threadid,title,postusername,replycount,lastpost,po stuserid,dateline$desc
FROM thread
WHERE forumid='$thread[forumid]'
ORDER BY dateline");
$validtitle = trim(strtolower($thread[title])," \t.");
$count = 0;
while ($rthread = $DB_site->fetch_array($rthreads)) {
$validthread = trim(strtolower($rthread[title])," \t.");
similar_text($validtitle, $validthread, &$similarity);
if($similarity > $priority){
$similar[title] = $rthread[title];
$similar[threadid] = $rthread[threadid];
$similar[postusername] = $rthread[postusername];
$similar[postuserid] = $rthread[postuserid];
$similar[replycount] = $rthread[replycount];
$similar[date] = vbdate($dateformat,$rthread[lastpost]);
$similar[description] = $rthread[description];
if (strlen($similar[description]) > 150) {
$similar[description] = substr($similar[description], 0, $previewcharacters) . "..."; } else {
$similar[description] = $similar[description];
}
if($similar[threadid] != $thread[threadid] && $count < $limit){
$count++;
eval("\$similarthreadbits .= \"".gettemplate("showthread_similarthreadbits")."\";"); }
}
}
if($count != 0){
eval("\$similarthreads .= \"".gettemplate("showthread_similarthreads")."\";"); }
////////////////////////////
// End Similar Threads /////
////////////////////////////
Now look at this block of code from above:
//////////////////////////// CONFIGURE ////////////////////////////////
$description_option = 0; //1 = on, 0 = off. (use only if you have THREAD descriptions installed)
if($description_option){ $desc = ",description"; }
$limit = 4; //Set the limit to the maximum amount of results to display
$priority = 60; //KEY: [less accurate, more results <0 --- 25 ---- 50 ---- 75 --- 100> more accurate, less results]
$previewcharacters = 150; //Amount of characters shown in the preview
///////////////////////////////////////////////////////////////////////
As detailed, those variables change how this hack works. The main thing you need to notice is $priority, which at default is set at 60, which I've found on my forums to be good. As said in the KEY in comments, a higher priority will get you more accurate similar threads, but less results. Ofcourse, a high priority is ideal for a large forum. Lower priority vice versa.
#2. Create a new template called
showthread_similarthreads, and place inside:
<table cellpadding="{_tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{_tablebordercolor}" {_tableouterextra} width="{_contenttablewidth}" align="center">
<tr><td>
<table cellpadding="4" cellspacing="{_tableinnerborderwidth}" border="0" {_tableinnerextra} width="100%">
<tr>
<td bgcolor="{_tableheadbgcolor}" width="{_tablewidth}" colspan="4" align="center">
<normalfont color="{_tableheadtextcolor}">
<b>Similar Threads</b></normalfont></td>
</tr>
<tr align="center" bgcolor="{_categorybackcolor}" background="https://vborg.vbsupport.ru/images/catagory_backing.gif">
<td align="center" nowrap><span><smallfont><b>Thread</b></smallfont></span></td>
<td nowrap><span><b><smallfont>Thread Starter</smallfont></b></span></td>
<td nowrap><span><smallfont><b>Replies</b></smallfont></span></td>
<td nowrap><span><smallfont><b>Last Post</b></smallfont></span></td>
</tr>
$similarthreadbits
</table>
</td></tr></table>
<br>
In the code above, take out all the underscores (ie. _) out of the replacement variables, such as {_tablewidth}, or else they will not work.
#3. Create a new template called showthread_similarthreadbits, and place inside:
<tr align="center">
<td width="60%" align="left" bgcolor="{_firstaltcolor}"><normalfont>
<a href="showthread.php?s=$session[sessionhash]&forumid=$thread[forumid]&threadid=$similar[threadid]"
title="$similar[description]">$similar[title]
</a></normalfont></td>
<td width="20%" bgcolor="{_secondaltcolor}" nowrap="nowrap"><normalfont>
<a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$similar[postuserid]">$similar[postusername]
</a></normalfont></td>
<td bgcolor="{_firstaltcolor}"><normalfont>$similar[replycount]</normalfont></td>
<td bgcolor="{_secondaltcolor}" width="20%"><normalfont>$similar[date]</normalfont>
</td>
</tr>
In the code above, take out all the underscores (ie. _) out of the replacement variables, such as {_secondaltcolor}, or else the colors wont show.
#4. In the template showthread, find:
<!-- thread options links -->
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#0A293E" align="center"><tr><td>
On the line above it place:
$similarthreads
------------- End -------------
That's it! Pretty easy and quick to install, which is the nicest part about it. :)
If you use this hack remember, please click install! Without it, you might have had to wait till vB3 ;)