Thread: Forum Display Enhancements - Thread Thumbnail
View Single Post
  #170  
Old 07-02-2008, 02:38 PM
theOZer's Avatar
theOZer theOZer is offline
 
Join Date: Mar 2007
Location: Colorado, USA
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 />
         &nbsp;
       </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 />
         &nbsp;
       </if>
     </if>
   </if>
   </td>
</if>
<!-- end of Thread Thumbnails -->
Enjoy!

Regards, theOZer
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01090 seconds
  • Memory Usage 1,794KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete