MyBB Hacks

Full Version: Filtering Thread By Thread Author
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Did you try to use GROUP BY a.tid in the query?
Hi RateU, this is the code I tried:

Code:
		$query = $db->query('
			SELECT t.*, f.name, a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename
			FROM '.TABLE_PREFIX.'threads t
			LEFT JOIN '.TABLE_PREFIX.'xtattachments a ON (a.tid=t.tid)
			LEFT JOIN '.TABLE_PREFIX.'forums f ON (f.fid=t.fid)
			WHERE t.visible=1 AND t.uid='.intval($memprofile['uid']).' AND closed NOT LIKE "moved|%" AND t.fid IN ('.implode(',', $mnxtigp_fid_array).')'.$mnxtigp_unviewwhere.'
			'.$mnxtigp_lr.'
			GROUP BY a.tid
			LIMIT 0,'.intval($mybb->settings['mnxtigp_num']).'


But its giving me a syntax error. I tried putting the group thing in other places in the code but failed :/

Try to put it above the $mnxtigp_lr variable?

Code:
GROUP BY a.tid
'.$mnxtigp_lr.'

Aha - that kind of worked - but see my profile page result:

http://easycaptures.com/fs/uploaded/426/5949684533.jpg

It seems that only the last post is showing in the preset format - and then with no picture...

BTW, I like fixing it like this - helps me to learn Smile
It seems the URL lead to your download attachment (.rar file). Try to change the query like this:

PHP Code:
		$query = $db->query('
			SELECT t.*, f.name, a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename
			FROM '.TABLE_PREFIX.'threads t
			LEFT JOIN '.TABLE_PREFIX.'xtattachments a ON (a.tid=t.tid)
			LEFT JOIN '.TABLE_PREFIX.'forums f ON (f.fid=t.fid)
			WHERE t.visible=1 AND t.uid='.intval($memprofile['uid']).' AND t.closed NOT LIKE "moved|%" AND a.thumbs!="" AND t.fid IN ('.implode(',', $mnxtigp_fid_array).')'.$mnxtigp_unviewwhere.'
			GROUP BY a.tid
			'.$mnxtigp_lr.'
			LIMIT 0,'.intval($mybb->settings['mnxtigp_num']).'
		');

aha, that got it to work. Is that because the a.thumbs is now BEFORE the implode function?
Yes. The a.thumbs there will "order" the query to find the attachments in that thread which has thumbnail. Because file "doesn't have" a thumbnail, so, it will try to find another attachment in the thread which has thumbnail. And the query find an image which has a thumbnail, then pull it to profile. I think like that (sorry if I'm wrong Biggrin).
I see, and then the group by tid makes it so that IF there was a thread with two images it first goes finds the first images and then goes through again?

So if I was to select MORE images in the plug in settings than I have threads then it would show some threads twice?
(08-15-2010 09:20 AM)leefish Wrote: [ -> ]I see, and then the group by tid makes it so that IF there was a thread with two images it first goes finds the first images and then goes through again?

It will go to another thread if the query already find an image there.

(08-15-2010 09:20 AM)leefish Wrote: [ -> ]So if I was to select MORE images in the plug in settings than I have threads then it would show some threads twice?

Nope (I think). It will make the thread id "unique" in profile.
Hi RateU, here is what I did with the code you posted. Thank you very much again.

http://www.leefish.nl/mybb/member.php?ac...http://www.leefish.nl/mybb/member.php?action=pro
Pages: 1 2 3 4
Reference URL's