Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Closed Thread
 
Thread Tools
vB3 Similar Threads Details »»
vB3 Similar Threads
Version: 1.00, by Velocd Velocd is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 08-16-2002 Last Update: Never Installs: 53
 
No support by the author.

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)

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/showth...p?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


------------- Installation -------------

#1. In showthread.php, find:
PHP Code:
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:
PHP Code:
//////////////////////////////////////////////////
// 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,postuserid,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:
PHP Code:
//////////////////////////// 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:
Code:
<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:
Code:
<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:
Code:
<!-- thread options links -->
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#0A293E"   align="center"><tr><td>
On the line above it place:
Code:
$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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #42  
Old 08-18-2002, 08:06 PM
The Realist's Avatar
The Realist The Realist is offline
 
Join Date: Oct 2001
Location: UK
Posts: 842
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Were are the pages for this hack generated and is there a way to test it works?

Installed but so far no errors?

Regards,

Brian
  #43  
Old 08-19-2002, 09:15 PM
newsguy newsguy is offline
 
Join Date: Feb 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this hack!

Installed nicely.

The relevance of the similar threads, though, is not all that great, even with tweaking the $priority variable.

But it's still a nice feature.
  #44  
Old 08-20-2002, 04:01 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

step #2:

<tr align="center" bgcolor="#336D95" background="https://vborg.vbsupport.ru/images/catagory_backing.gif">

Other than the "catagory" typo is there a recommended image? or just zap it?

Regards,

Matt
  #45  
Old 08-20-2002, 05:08 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<tr align="center" bgcolor="{_categorybackcolor}"> ,without the space ofcourse.

I'm actually not sure what you're talking about, but give that a try (very late..sleepy..must get sleep O_O)
  #46  
Old 08-23-2002, 08:00 AM
Darth Cow's Avatar
Darth Cow Darth Cow is offline
 
Join Date: Nov 2001
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might want to only select threads from, say, the last month to help aliviate the performance issue.
  #47  
Old 08-24-2002, 06:08 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Minor bug -

1) The similar threads search occasionally pulls up the title of a post that was Moved (with redirect) to another forum.

The result is that if you click on one of those, you'll get a screen with header and message title but no body, and the forum thinks it's an empty poll or something.

2) Looks like this:

http://forum.bonsaitalk.com/showthre...&threadid=1634

3) I'm thinking it would be possible to fix this because the forum's internal search never returns redirected posts, so there must be a flag or prefix or something to identify them.

4) If you don't know what's going on, it is a little bewildering, but it did give me the idea for a new hack:

SHOW/PURGE REDIRECTS!

I having to jump through hoops to purge a redirect. You have to move it back to the original forum, then move it forward. If there were a hack to display or purge redirects older than XX days, it would be very cool!

Regards,

Matt
  #48  
Old 09-15-2002, 02:15 PM
Craigr's Avatar
Craigr Craigr is offline
 
Join Date: May 2002
Location: Ayr, Scotland
Posts: 194
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Velocd
hmm, that is an odd error.

Try replacing:
PHP Code:
$validtitle trim(strtolower($thread[title])," \t.");
$count 0;

while (
$rthread $DB_site->fetch_array($rthreads)) {
    
$validthread trim(strtolower($rthread[title])," \t."); 
With:
PHP Code:
$validtitle trim($thread[title]," \t.");
$validtitle strtolower($validtitle);
$count 0;

while (
$rthread $DB_site->fetch_array($rthreads)) {
    
$validthread trim($rthread[title]," \t.");
    
$validthread strtolower($validthread); 
My guess is you are using possibly an older version of PHP maybe, and it's not functional with more than one parameter..(something like that)..:P
I had the same problem on my board:
Warning: Wrong parameter count for trim() in showthread.php on line ???

I tried replacing this, but it still doesn't work.

Any ideas? I have the store hack added too.

Thanks
Craig
  #49  
Old 09-16-2002, 06:45 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm guessing maybe you're on an older PHP version maybe, and it's not updated for the correct parameters..

Anyway, try replacing:
PHP Code:

$validtitle 
trim(strtolower($thread[title])," \t.");
$count 0;

while (
$rthread $DB_site->fetch_array($rthreads)) {
    
$validthread trim(strtolower($rthread[title])," \t."); 
With just:
PHP Code:

$validtitle 
trim($thread[title]);
$validtitle strtolower($validtitle);
$count 0;

while (
$rthread $DB_site->fetch_array($rthreads)) {
    
$validthread trim($rthread[title]);
    
$validthread strtolower($validthread); 
  #50  
Old 09-17-2002, 01:50 PM
Craigr's Avatar
Craigr Craigr is offline
 
Join Date: May 2002
Location: Ayr, Scotland
Posts: 194
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did that, but got the same error.

Craig
  #51  
Old 09-20-2002, 06:06 AM
speedway's Avatar
speedway speedway is offline
 
Join Date: Nov 2001
Location: Sydney, Australia
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It seems that the additional parameter for the "trim" function was introduced in PHP 4.1 - so for those of us under that this hack will not work.

From php.net
Quote:
trim
(PHP 3, PHP 4 )

trim -- Strip whitespace from the beginning and end of a string
Description
string trim ( string str [, string charlist])


Note: The optional charlist parameter was added in PHP 4.1.0

Velocd - you should edit your original thread to reflect this requirement - so people do not try to install this if they do not meet the PHP requirement.
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05338 seconds
  • Memory Usage 2,369KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete