Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Improved Thread Preview Hack Details »»
Improved Thread Preview Hack
Version: 1.00, by N!ck N!ck is offline
Developer Last Online: Oct 2008 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 03-02-2002 Last Update: Never Installs: 88
 
No support by the author.

The idea for this hack was originally that of Parker Clack, a regular here on vBulletin.org.

What this hack does:
Basically, this hack pops up a little box/window when the mouse is run over a thread title that shows the first three hundred characters of the first post in the thread (that is, the post that started the thread).

Improvements to Parker Clack's hack:
  • Far, far less code...
  • Easier installation (one file edit, one template edit)...
  • Less space usage...the beginning of the first post in each thread is not stored twice - only once now!...

Versions:
3.0: Overgrow's search page thread preview instructions.
2.1: Added some necessary instructions.
2.0 Reduced MySQL queries significantly.
1.0 Initial release.

Comments appreciated...

A version for vbHacker is available here - note: some files may need fixing afterward if they present parse errors!

How to Censor Previews (by nakkid)
See page seven of this thread.

A very important security fix is available here - I have not updated the ZIP, so install it after you install the hack

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 03-03-2002, 06:03 PM
N!ck N!ck is offline
 
Join Date: Mar 2002
Location: Lake Havasu City, AZ
Posts: 886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i have an idea...overgrow, post your forumdisplay.php as an attachment and i'll look at that part...

you and freddie will get credit now as well, of course
Reply With Quote
  #23  
Old 03-03-2002, 07:19 PM
Overgrow's Avatar
Overgrow Overgrow is offline
 
Join Date: Nov 2001
Posts: 320
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

>>overgrow, post your forumdisplay.php as an attachment

Sorry, can't post whole vB files as it violates the license. Freddie made this super easy though.. I see no reason why this wasn't suggested as the first way to code the hack. Here is the important part of forumdisplay.. add the first part and modify the query by including $previewselect and $previewjoin.

PHP Code:
// HACK POST PREVIEW
    
$previewselect="post2.pagetext as pagetext,";
    
$previewjoin="LEFT JOIN post AS post2 ON (thread.firstpostid = post2.postid)";
// END PREVIEW

$threads=$DB_site->query("
SELECT 
$dotuserid $votequery $previewselect "
.iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
    thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
    lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
    FROM thread
    "
.iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
    
$dotjoin $previewjoin
    WHERE 
$threadids
    ORDER BY sticky DESC, 
$sortfield $sqlsortorder
    "
); 

One of my users asked why this didn't work for search results, so that is pretty easy to move over. Search.php

find:

PHP Code:
$dotuserid '';
      
$dotjoin '';
    } 
below that add

PHP Code:
// HACK POST PREVIEW
    
$previewselect="post2.pagetext as pagetext,";
    
$previewjoin="LEFT JOIN post AS post2 ON (thread.firstpostid = post2.postid)";
    
// END PREVIEW 

find

user.userid AS postuserid,

replace with

user.userid AS postuserid, $previewselect


find

LEFT JOIN icon AS threadicon ON thread.iconid=threadicon.iconid
$dotjoin

replace with

LEFT JOIN icon AS threadicon ON thread.iconid=threadicon.iconid
$dotjoin $previewjoin


find

PHP Code:
$searchresult['pagetext'] = $ignoreduser;
        
$searchresult['posttitle'] = $ignoreduser;
      } else { 
below that add

PHP Code:
// POST PREVIEW HACK
        
$searchresult[pagetext]=preg_replace("/\[[^\]]*\]/","",$searchresult[pagetext]);
        
$searchresult[pagetext]=str_replace("\"","",$searchresult[pagetext]);
        if (
strlen($searchresult[pagetext]) > 300) {
         
$fppreview substr($searchresult[pagetext], 0300) . "...";
        } else {
         
$fppreview $searchresult[pagetext];
        }
        
// END PREVIEW 
Then put $fppreview in the searchresultbit_threadonly template.

I noticed this was your first project so I hope you write this all up into a new hack so it's not confusing for the other users. thanks~
Reply With Quote
  #24  
Old 03-03-2002, 08:42 PM
N!ck N!ck is offline
 
Join Date: Mar 2002
Location: Lake Havasu City, AZ
Posts: 886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ouch...forgot about the license... :O

okay...well this is the error i get (again, i'm not sure whether it's related to this 'dotqueries' thing ):

Code:
Database error in vBulletin 2.2.2:

Invalid SQL: 
SELECT DISTINCT post.userid,  post2.pagetext as pagetext, icon.title as icontitle,icon.iconpath,
    thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
    lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
    FROM thread
    LEFT JOIN icon ON (icon.iconid = thread.iconid)
    LEFT JOIN post ON (thread.threadid = post.threadid AND post.userid = '1') LEFT JOIN post AS post2 ON (thread.firstpostid = post2.postid)
    WHERE thread.threadid IN (0,8,17,1,15,7)
    ORDER BY sticky DESC, lastpost DESC
    
mysql error: Unknown column 'thread.firstpostid' in 'on clause'

mysql error number: 1054

Date: Sunday 03rd of March 2002 05:43:42 PM
Script: http://www.60schevytrucks.com/forums...p?s=&forumid=4
Referer: http://www.60schevytrucks.com/forums/
Reply With Quote
  #25  
Old 03-03-2002, 08:57 PM
Overgrow's Avatar
Overgrow Overgrow is offline
 
Join Date: Nov 2001
Posts: 320
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not sure what to tell you.. this is right out of my forumdisplay.php and it works. I just turned on "Use Dot Icons" in the Cpanel, which affects this query, and they both worked at the same time.. which was the main goal. The second join slowed it down, too much for my site, but probably OK for others.
Reply With Quote
  #26  
Old 03-03-2002, 08:58 PM
Overgrow's Avatar
Overgrow Overgrow is offline
 
Join Date: Nov 2001
Posts: 320
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// HACK POST PREVIEW
    
$previewselect="post2.pagetext as pagetext,";
    
$previewjoin="LEFT JOIN post AS post2 ON (thread.firstpostid = post2.postid)";
// END PREVIEW

$threads=$DB_site->query("
SELECT 
$dotuserid $votequery $previewselect ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
    thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
    lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
    FROM thread
    "
.iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
    
$dotjoin $previewjoin
    WHERE 
$threadids
    ORDER BY sticky DESC, 
$sortfield $sqlsortorder
    "
); 
Reply With Quote
  #27  
Old 03-03-2002, 09:26 PM
Freddie Bingham's Avatar
Freddie Bingham Freddie Bingham is offline
 
Join Date: Oct 2001
Posts: 506
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

'thread.firstpostid' isn't a default field in vBulletin. It makes the hack easy as you know what to join on but you have to make other modifications to newthread to save the first postid when the thread is created. I saw it in the queries you guys posted but I don't see it in the hack instructions so I was wondering how you were making this work without creating that field.
Reply With Quote
  #28  
Old 03-03-2002, 09:28 PM
Freddie Bingham's Avatar
Freddie Bingham Freddie Bingham is offline
 
Join Date: Oct 2001
Posts: 506
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it is slowing you down, make sure you have put an index on "thread.firstpostid" otherwise you are going to have a full thread table scan which is bad(tm).
Reply With Quote
  #29  
Old 03-03-2002, 10:21 PM
N!ck N!ck is offline
 
Join Date: Mar 2002
Location: Lake Havasu City, AZ
Posts: 886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i made it work...i even made an install script to add and populate the extra field works like a charm, expect an update tonight
Reply With Quote
  #30  
Old 03-04-2002, 02:42 AM
N!ck N!ck is offline
 
Join Date: Mar 2002
Location: Lake Havasu City, AZ
Posts: 886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

update released!

thread previews on searches will be in the next update
Reply With Quote
  #31  
Old 03-04-2002, 08:38 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm using Parker's fantastic hack with no problems. How much does this hack improve on Parker's? I'm just wondering whether it is worth the changeover...
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04689 seconds
  • Memory Usage 2,333KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete