Adding Thread Thumbnails to Tag Search
Salute to Jason Merchant the original coder of this excellent Thread Thumbnails mod. Salute to vB.org for hosting this mod's thread.
This is a 'How I Did It.' I hope this is ethically correct that I can post this tweak, seeing how I stole the plugin from Jason and tags.php needs to be modified. I have this up-and-running on my forum; it works for me, okay?
tags.php needs to be slightly tweaked to make this all happen.
You will need to install a plugin.
You will need to modify your threadbit template(s).
[Note: Before changing your current tags.php file make a backup copy named tags_original.php, for example.]
A) Tweak the tags.php file:
Change tags.php
>>Find:
$hook_query_fields = $hook_query_joins = '';
($hook = vBulletinHook::fetch_hook('tags_list_query_data')) ? eval($hook) : false;
>>Change the 1st line to:
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('tags_list_query_data')) ? eval($hook) : false;
At the bottom of the following select statement -
>>Find:
$hook_query_joins
WHERE thread.threadid IN (" . implode(',', $threadids) . ")
>>Change the 2nd line to:
$hook_query_joins
WHERE thread.threadid IN (" . implode(',', $threadids) . ") $hook_query_where
B1) Create the plugin .xml file:
Copy the following xml code, pasting it into Wordpad or Notepad. Save the file as a .xml. For example, I named mine: thread-thumbnail-plugins-tags.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" executionorder="5" product="vbulletin">
<title>Thread Thumbnail - Tag Search</title>
<hookname>tags_list_query_data</hookname>
<phpcode><![CDATA[$tt_displaythumbs_tags = true;
$hook_query_fields .= ", attachment.thumbnail_filesize AS thumbsize , MIN(attachment.attachmentid) AS attachmentid ";
$hook_query_joins .= "LEFT JOIN " . TABLE_PREFIX . "attachment as attachment ON(attachment.postid = thread.firstpostid AND (attachment.extension = 'jpg' OR attachment.extension = 'gif' OR attachment.extension = 'png')) ";
$hook_query_where .= "GROUP BY thread.threadid ";]]></phpcode>
</plugin>
</plugins>
B2) Import the plugin:
In Admin Control Panel > Plugins & Products > Download/Upload Plugins > Import Plugin Definitions XML File window, Import the .xml file you just created.
C) threadbit template changes:
Here's
my New & Improved threadbit template change to thread thumbnail both regular searches and Tag searches. Your current TT code may differ from mine, for sure.
Code:
<!-- Thread Thumbnails -->
<if condition="$show['threadicons']">
<td class="alt2" align="center" valign="middle">
<!-- TAG Search Thread Thumbnails -->
<if condition="($tt_displaythumbs_tags)">
<if condition="($thread['attachmentid']) AND ($thread['thumbsize'])">
<a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
<img src="attachment.php?attachmentid=$thread[attachmentid]&stc=1&thumb=1" alt="" border="0" />
</a>
<else />
<if condition="$show['threadicon']">
<img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
<else />
</if>
</if>
<else />
<!-- Thread Thumbnails in Forums & Search -->
<if condition="($tt_displaythumbs)">
<if condition="($thread['attachmentid']) AND ($thread['thumbsize'])">
<a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
<img src="attachment.php?attachmentid=$thread[attachmentid]&stc=1&thumb=1" alt="" border="0" />
</a>
<else />
<img src="$stylevar[imgdir_misc]/nothumb.jpg" alt="" border="0" />
</if>
<else />
<if condition="$show['threadicon']">
<img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
<else />
</if>
</if>
</if>
</td>
</if>
<!-- end of Thread Thumbnails -->
Enjoy!
Regards, theOZer