MyBB Community Forums

Full Version: Merging Two Plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have this plugin here:
http://www.thingiej.be/RecentThreadsInProfile.rar

This basically displays the users latest threads on their profiles, created by LeX- and that works perfectly fine.

I'm trying to edit the code to allow the first thumbnail from each thread show up on the profiles. LeX- made a code edit for forum display that does exactly this, but I'm trying to get it to work on profiles now. He appears to query similar things, but I'm not good with php or mysql for that matter, I'm very new, and any help or advice would be very much appreciated.

I did ask LeX- if he could do it and if it was possible. He said he's currently to busy to do it but that it indeed is possible to achieve.

The thumbnail code, as it is now, places into Forumdisplay.php after:

	else
		{
			$attachment_count = '';
		}

This places below that code.
 // GET FIRST ATTACHMENT
        $attachment_thumbnail = '';
        if($attachment_count)
        {
            $query = $db->query("
                       SELECT a.thumbnail
                    FROM ".TABLE_PREFIX."attachments a
                LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
                    WHERE p.tid='{$thread['tid']}' AND a.filetype LIKE '%image%'
                        ORDER BY a.dateuploaded ASC
                LIMIT 0,1
                ");
            $thumbnail = $db->fetch_field($query, 'thumbnail');
            if($thumbnail)
            {
                $attachment_thumbnail = "<div style=\"float:left\"><img src=\"./uploads/{$thumbnail}\" /></div>";
            }
        }
It isn't as simple as merging the code the way you seem to think. That code you posted also has an associated template change as well.

However, in the plugin you MIGHT be able to do:

Change:
$threads .= "<img title=\"{$attach}{$t_reads['attachmentcount']}\" src=\"./images/paperclip.gif\" /> ";

To:
$attachment_thumbnail = '';
        if($attachment_count)
        {
            $query = $db->query("
                       SELECT a.thumbnail
                    FROM ".TABLE_PREFIX."attachments a
                LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
                    WHERE p.tid='{$thread['tid']}' AND a.filetype LIKE '%image%'
                        ORDER BY a.dateuploaded ASC
                LIMIT 0,1
                ");
            $thumbnail = $db->fetch_field($query, 'thumbnail');
            if($thumbnail)
            {
                $attachment_thumbnail = "<div style=\"float:left\"><img src=\"./uploads/{$thumbnail}\" /></div>";
            }
        } 
$threads .= "<img title=\"{$attachment_thumbnail}{$attach}{$t_reads['attachmentcount']}\" src=\"./images/paperclip.gif\" /> ";

But that's untested and I'm not 100% sure it will work. If I'm right that will put the thumbnail to the left of the paperclip. But, I could be wrong.
Thanks for helping, but that doesn't appear to work. Even after moving {$attachment_thumbnail} out of the title="*" attribute, which you may have place it in there by accident.

using {$attachment_thumbnail} doesn't show anything, not even the fixed stuff, and by that I mean <div style=".... etc. It just is completely blank.