MyBB Hacks

Full Version: Filter Threads By Thread Prefix - MyBB 1.6 Only
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Well, the one I posted works.... I will try yours too though Smile
^ I think {$thread} refers to the thread being viewed in showthread (so it will use the prefix of the current thread) whereas {$similar_thread} refers to the thread in the table row.
Yours may not work if these two use different prefixes I think.
Hi - I think maybe I was not clear - so here is a pic. I have discovered another issue with this layout though (related to editing)

[attachment=285]

My goal was to show the similar threads - at the moment its calling on similarity of name (which is ok, I can think of things for that) - I think Rateu was looking at similarity of prefix, which is also a good idea. Maybe I could combine them......
I'm a bit confused at what you're trying to say.

{$thread['prefix']} will take the prefix ID of the thread you're viewing
{$thread['threadprefix']} will display the prefix "name" of the thread you're viewing
{$similar_thread['prefix']} will take the prefix ID of the thread in the similar thread row
{$similar_thread['threadprefix']} will display the prefix "name" of the thread in the similar thread row

In the last code box you posted here, you're mixing the viewing thread's ID with the similar thread's name (so the link may be incorrect if the two are different).
(11-16-2010 11:33 AM)ZiNgA BuRgA Wrote: [ -> ]I'm a bit confused at what you're trying to say.

{$thread['prefix']} will take the prefix ID of the thread you're viewing
{$thread['threadprefix']} will display the prefix "name" of the thread you're viewing
{$similar_thread['prefix']} will take the prefix ID of the thread in the similar thread row
{$similar_thread['threadprefix']} will display the prefix "name" of the thread in the similar thread row

In the last code box you posted here, you're mixing the viewing thread's ID with the similar thread's name (so the link may be incorrect if the two are different).

Hi Zinga - what I am trying to say - in response to the post from RateU

(11-16-2010 01:47 AM)RateU Wrote: [ -> ]For the showthread_similarthreads_bit template, maybe you mean like this, Lee?

HTML Code
<a href="{$forumurl_q}filterxt_prefix={$similar_thread['prefix']}">{$similar_thread['threadprefix']}</a>


Is no, I did not mean to say something else - the snippet I posted worked - so does RateU's. Thats it. I have no idea if it is significant that they both work.

Code:
<td class="{$trow}"><a href="{$forumurl_q}filterxt_prefix={$thread['prefix']}">{$similar_thread['threadprefix']}</a>


What do I mean by worked? That the prefix shows up (as in pic) and if I click on that prefix while viewing the show thread it shows me all posts in that forum with that prefix.

Ok, I have been doing more testing on this - and now have a change of plan - what I am NOW trying to do is to get the threads with the same prefix OR with matching words of the currently viewed thread to show in the similar threads box.

Currently, the similar threads box is showing matches based on similar words in the title of the selected thread - what I am trying to do is get the threads with the same prefix as the selected thread to show. (It might be an idea to have a limit on it as well) - it makes no difference whether I use RateUs code or mine - it does not find the matching prefixes Frown

http://mybbhacks.zingaburga.com/attachment.php?aid=285
You'll need to modify the query to do that.
Find in showthread.php:

Code:
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']}'

And stick a AND t.prefix=<something> type term in there.

Hi Zinga - if I make it an AND won't that mean that unless a thread has a prefix it won't show up?


....I shall go test....
From memory, if a thread doesn't have a prefix, $thread['prefix'] should be 0, meaning the query will find all threads with no prefixes.
ok, I tried it - and no result - I think its because it is looking to do a match as the final piece of the query

PHP Code:
$query = $db->query("
				SELECT t.*, t.username AS threadusername, p.displaystyle AS threadprefix, u.username, MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') AS relevance
				FROM ".TABLE_PREFIX."threads t
				LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid = t.prefix)
				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.prefix='{$thread['prefix']}' 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']}
			");



I tried adding this

PHP Code:
$query = $db->query("
				SELECT t.*, t.username AS threadusername, p.displaystyle AS threadprefix, u.username, MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') AS relevance
				FROM ".TABLE_PREFIX."threads t
				LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid = t.prefix)
				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.prefix='{$thread['prefix']}' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.prefix) AGAINST ('".$db->escape_string($thread['prefix'])."') OR MATCH (t.subject) AGAINST ('".$db->escape_string($thread['subject'])."') >= '{$mybb->settings['similarityrating']}'
				ORDER BY t.lastpost DESC
				LIMIT 0, {$mybb->settings['similarlimit']}
			");


and got this error message

Code:
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1191 - Can't find FULLTEXT index matching the column list
Query:
SELECT t.*, t.username AS threadusername, p.displaystyle AS threadprefix, u.username, MATCH (t.subject) AGAINST ('SHOESballetenpointe meshes & uvmaps') AS relevance FROM mybb_threads t LEFT JOIN mybb_threadprefixes p ON (p.pid = t.prefix) LEFT JOIN mybb_users u ON (u.uid = t.uid) WHERE t.fid='46' AND t.tid!='1084' AND t.visible='1' AND t.prefix='2' AND t.closed NOT LIKE 'moved|%' AND MATCH (t.prefix) AGAINST ('2') OR MATCH (t.subject) AGAINST ('SHOESballetenpointe meshes & uvmaps') >= '4' ORDER BY t.lastpost DESC LIMIT 0, 10

Pages: 1 2 3 4 5 6
Reference URL's