Just tested and it hides all the posts!!!
Doesn't work?
Can anybody build a simple plugin out of this:
$similarthreads = '';
if($mybb->settings['showsimilarthreads'] != 0)
{
switch($db->type)
{
case "pgsql":
$query = $db->query("
SELECT t.*, t.username AS threadusername, u.username
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid), plainto_tsquery ('".$db->escape_string($thread['subject'])."') AS query
WHERE t.fid='{$thread['fid']}' AND t.tid!='{$thread['tid']}' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.subject @@ query
ORDER BY t.lastpost DESC
OFFSET 0 LIMIT {$mybb->settings['similarlimit']}
");
break;
default:
$query = $db->query("
SELECT t.*, t.username AS threadusername, u.username, MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') AS relevance
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
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']}'
ORDER BY t.lastpost DESC
LIMIT 0, {$mybb->settings['similarlimit']}
");
}
$count = 0;
$similarthreadbits = '';
$icon_cache = $cache->read("posticons");
while($similar_thread = $db->fetch_array($query))
{
++$count;
$trow = alt_trow();
if($similar_thread['icon'] > 0 && $icon_cache[$similar_thread['icon']])
{
$icon = $icon_cache[$similar_thread['icon']];
$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
}
else
{
$icon = " ";
}
if(!$similar_thread['username'])
{
$similar_thread['username'] = $similar_thread['threadusername'];
$similar_thread['profilelink'] = $similar_thread['threadusername'];
}
else
{
$similar_thread['profilelink'] = build_profile_link($similar_thread['username'], $similar_thread['uid']);
}
// If this thread has a prefix, insert a space between prefix and subject
if($similar_thread['prefix'] != 0)
{
$prefix = build_prefixes($similar_thread['prefix']);
$similar_thread['threadprefix'] = $prefix['displaystyle'].' ';
}
$similar_thread['subject'] = $parser->parse_badwords($similar_thread['subject']);
$similar_thread['subject'] = htmlspecialchars_uni($similar_thread['subject']);
$similar_thread['threadlink'] = get_thread_link($similar_thread['tid']);
$similar_thread['lastpostlink'] = get_thread_link($similar_thread['tid'], 0, "lastpost");
$lastpostdate = my_date($mybb->settings['dateformat'], $similar_thread['lastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $similar_thread['lastpost']);
$lastposter = $similar_thread['lastposter'];
$lastposteruid = $similar_thread['lastposteruid'];
// Don't link to guest's profiles (they have no profile).
if($lastposteruid == 0)
{
$lastposterlink = $lastposter;
}
else
{
$lastposterlink = build_profile_link($lastposter, $lastposteruid);
}
$similar_thread['replies'] = my_number_format($similar_thread['replies']);
$similar_thread['views'] = my_number_format($similar_thread['views']);
eval("\$similarthreadbits .= \"".$templates->get("showthread_similarthreads_bit")."\";");
}
if($count)
{
eval("\$similarthreads = \"".$templates->get("showthread_similarthreads")."\";");
}
}
D666 baby thanks very much but it doesn't work please take a look at snapshots
<?=str_replace('<!--SIMILAR_THREADS-->', $similarthreads, $posts)?>
This is PHP not conditional!!!!!!!!!