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

NeverBored, Nice approach.

The forum exclusion logic NeverBored wrote could also be incorporated into this plugin tweak of mine, making it at that point a fairly comprehensive as well as solid mod/hack that covers all the bases.

First & Foremost do this/test this in your testvb forum before actually doing this in your forrealzie vB forum.

This Thread Thumbnail tweak:
  • Keeps Jason's original 'your selected forum IDs' thread thumbnail logic in place, which shows NO THUMBNAIL AVAILABLE if no thread 1st post thumbnail.
  • Adds thread thumbnail display to all other forums. If there's no thread 1st post thumbnail then the vB default thread icon is displayed.
  • All img lines of code have been wrapped in href tags, not just the thumbnailed threads. [If this adds "Server Issues" then delete the href open/close a tag code wrap.]
Installation instructions:

1) Temp Disable, with eventual intent to delete, the Thread Thumbnail plugin.

2) Save the following code as an XML file, naming it whatever you want, e.g., thread-thumbnail-plugins-all-forums.xml. Then load this XML file through your Admin Control Panel > Plugins & Products > Download/Upload Plugins > Import Plugin Definitions XML File window, Import the .xml file you just created. This creates plugin 'Thread Thumbnails - All Forums'.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" executionorder="5" product="vbulletin">
<title>Thread Thumbnail - All Forums</title>
<hookname>forumdisplay_query</hookname>
<phpcode><![CDATA[$tt_thumbsforums = array(2);
$tt_displaythumbs = false;
if (in_array($forumid, $tt_thumbsforums)) {
$tt_displaythumbs = true;
}
$tt_displaythumbs_all = 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>
Add the forum IDs you want thumbnailed, the ones where you definitely expect art post attachments, to the $tt_thumbsforums array.

Click on a forum you want thumbnailed(, or look it up in AdminCP > Forums & Moderators > Forum Manager).
In the browser window you should see something like this:
yourforum.com/forums/forumdisplay.php?f=36
IN THIS EXAMPLE, 36 is your forum's forum ID. This goes in the array.
In AdminCP edit your Thread Thumbnail plugin, adding forum 36 to the array:
example, $tt_thumbsforums = array(36);
Separate multiple forums you want thumbnailed with a comma (,):
example, $tt_thumbsforums = array(36, 37);

3) In all your threadbit templates add this code tweaking it to your liking.

[Note: This code includes IF statements that handle thumbnailing 1) Tag Searches (see vB.org, Thread Thumbnails, page 13, Post # 193), 2) New Posts & regular Searches (see vB.org, Thread Thumbnails, page 12, Post # 169), 3) forums (original mod logic). Delete the IF statement section(s) that do NOT apply to you.]

Find in threadbit template:
Code:
<if condition="$show['threadicons']">
<td class="alt2"><if condition="$show['threadicon']"><img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" /><else />&nbsp;</if></td>
</if>
Replace with:
Code:
<!-- OMAC Thread Thumbnails -->
<!-- in this code:  -->
<!-- All img lines of code have been wrapped in href tags, not just threads with thumbnails -->
<if condition="$show['threadicons']">
   <td class="alt2" align="center" valign="middle">
<!-- Tag Search -->
   <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 />
<!-- and, don't forget to close all the If stmts with vB's original If stmt code that we've just bastardized. -->
       <if condition="$show['threadicon']">
        <a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
         <img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
        </a>
       <else />
         &nbsp;
       </if>
     </if>
<!-- end_of Tag Search -->
   <else />
<!-- New Posts & regular Search -->
     <if condition="($tt_displaythumbs_search)">
       <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 />
<!-- and, don't forget to close all the If stmts with vB's original If stmt code that we've just bastardized. -->
         <if condition="$show['threadicon']">
           <a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
           <img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
           </a>
         <else />
           &nbsp;
         </if>
       </if>
<!-- end_of New Posts & regular Search -->
     <else />
<!-- Thread Thumbnails in All Forums -->
<!-- Your forum IDs you added to the $tt_thumbsforums array will show thread 1st post thumbnail or the "NO THUMBNAIL AVAILABLE" icon -->
       <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 />
           <a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
           <img src="$stylevar[imgdir_misc]/nothumb.jpg" alt="" border="0" />
           </a>
         </if>
       <else />
<!-- All Your NON-selected forums will show thread 1st post thumbnail or the vB default thread post icon -->
         <if condition="($tt_displaythumbs_all)">
           <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 />
<!-- and, don't forget to close all the If stmts with vB's original If stmt code that we've just bastardized. -->
             <if condition="$show['threadicon']">
               <a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
                 <img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
               </a>
             <else />
               &nbsp;
             </if>
           </if>
<!-- end_of Thread Thumbnails in All Forums -->
         <else />
<!-- and, don't forget to close all the If stmts with vB's original If stmt code that we've just bastardized. -->
           <if condition="$show['threadicon']">
             <a href="showthread.php?$session[sessionurl]t=$thread[threadid]">
               <img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" />
             </a>
           <else />
             &nbsp;
           </if>
         </if>
       </if>
     </if>
   </if>
   </td>
</if>
<!-- end of OMAC Thread Thumbnails -->
Once you get this to work then go ahead and delete the original Thread Thumbnail plugin -OR- just keeping it disabled works too.

~OZ
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01193 seconds
  • Memory Usage 1,811KB
  • 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
  • (3)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