MyBB Community Forums

Full Version: Possibly Related Threads in a Forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

The Possibly Related Threads works fine, but how to show the similar thread from a forum (but not the standard section). So the similar thread name would be searched in all sections of a forum. Section limitation is basically not optimal from the start.

Thanks for attention
You'll need a core file edit or a plugin.

Line 980 of showthread.php:
WHERE t.fid='{$thread['fid']}' AND t.tid!='{$thread['tid']}' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') >= '{$mybb->settings['similarityrating']}'

Replace with:
WHERE t.tid!='{$thread['tid']}' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') >= '{$mybb->settings['similarityrating']}'
It works perfectly thanks a lot. Smile

Can it also show from which from is a thread ?

Ive looked at showthread_similarthreads_bit and added the code (from search_results_threads_thread)
{$thread['forumlink']}

But it didnt work, please if its not to difficult look also at this question.

Thanks for your support Smile


{$thread['forumlink']} is not a valid code. try this;
<a href="forumdisplay.php?fid={$thread['fid']}">{$forum['name']}</a>
Thanks for answering but it displays the name of only one forum, the name of the forum in which the viewing thread is located, but not the different forums names, according to different threads.

{$similar_thread['fid']}
Result
28

So its close Big Grin but i need to change the 'fid' to forum'name', all my variants didn't succeed.

{$similar_thread['forumname']} /// doesn't work
I don't know if this is still relevant (and if it isn't, I'm sorry for necroposting), but I came across this topic in my search for a way to do exactly what the OP wanted, and I have now figured out my own solution, so I thought I'd share it.

As AJS said, the section of showthread.php pertaining to related threads starts at line 980.
Editing line 1000 from this:
WHERE t.fid='{$thread['fid']}' AND t.tid!='{$thread['tid']}' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') >= '{$mybb->settings['similarityrating']}'
to this:
WHERE t.tid!='{$thread['tid']}' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') >= '{$mybb->settings['similarityrating']}'
removes the criterion that the related threads must be located in the same sub-section of your board.
Thanks for this info, AJS. It was very helpful.

You may also want to edit line 1001 from this:
ORDER BY t.lastpost DESC
to this:
ORDER BY 'similarityrating'
so that the related threads are ordered by their similarity to the current thread rather than when they were last posted in.

Now add these two lines somewhere in the while statement, which starts at line 1009:
$similar_thread['forumlink'] = get_forum_link($similar_thread['fid']);
$similar_forum = get_forum($similar_thread['fid']);
Personally, I added them after line 1041 because we want to use the new variables in conjunction with the ones defined in lines 1039-1041 ($similar_thread['subject'] and $similar_thread['threadlink']).

Now, go to your showthread_similarthreads_bit template and edit line 3 from this:
<td class="{$trow}">{$similar_thread['threadprefix']}<a href="{$similar_thread['threadlink']}">{$similar_thread['subject']}</a></td>
to this:
<td class="{$trow}">{$similar_thread['threadprefix']}<a href="{$similar_thread['threadlink']}">{$similar_thread['subject']}</a> in <a href="{$similar_thread['forumlink']}">{$similar_forum['name']}</a></td>
and it should work.