vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Improved Thread Preview Hack (https://vborg.vbsupport.ru/showthread.php?t=35645)

N!ck 03-02-2002 10:00 PM

Improved Thread Preview Hack
 
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

Overgrow 03-03-2002 05:28 AM

HEY that is really nice. I like it, flawless installation and very simple code.

I don't like that it adds a query on the post table for each thread listed.. that's an extra 40 or 50 queries with each forumdisplay. Is it possible to compile a list of all threads that will be displayed on the page and then run one query and pull all the post info at once?

Right now I have it only operating for admins since I don't want to add so much extra load. Thanks, nice work.

N!ck 03-03-2002 05:31 AM

as far as i know, the choices are a) store the same data twice for every single thread or b) run a few extra queries! :)

maybe someone can prove me wrong or i can ponder it for awhile

N!ck 03-03-2002 05:39 AM

yeah...looking at it, i'm almost positive the only way is to run extra queries

Overgrow 03-03-2002 05:52 AM

Nope, a join will do it. I've got it re-written..

old way: mysql things 1.10 seconds
new way: mysql things 0.09 seconds

Only problem is it joins the post table again which won't work if you have dotqueries turned on. It will take a little more re-writing to get it to work with dotqueries.

PHP Code:

// HACK POST PREVIEW
if($bbuserinfo['usergroupid']==and $showposts!="off") {
    
$previewselect="post.pagetext as pagetext,";
    
$previewjoin="LEFT JOIN post ON (thread.firstpostid = post.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
    "
); 

Then reference thread[pagetext] down below instead of running the query each time. Works like a charm without the extra db overhead, but like I said, will take a little tweaking to get it to go with dotqueries.

Overgrow 03-03-2002 05:54 AM

You want to finish it up? :D

N!ck 03-03-2002 05:55 AM

okay...thanks...i'll test that out and issue an update

N!ck 03-03-2002 06:02 AM

well....i got a database error. i must have done something wrong.

N!ck 03-03-2002 06:06 AM

Database error in vBulletin 2.2.2:

Invalid SQL:
SELECT DISTINCT post.userid, post.pagetext as pagetext, icon.title as icontitle,icon.iconpath,
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postus erid,
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 ON (thread.firstpostid = post.postid)
WHERE thread.threadid IN (0,13,16)
ORDER BY sticky DESC, lastpost DESC

mysql error: Not unique table/alias: 'post'

mysql error number: 1066

Date: Sunday 03rd of March 2002 03:08:13 AM
Script: http://www.60schevytrucks.com/forums...p?s=&forumid=6
Referer: http://www.60schevytrucks.com/forums...s=&threadid=13

Overgrow 03-03-2002 06:09 AM

Yup, you have dotqueries turned on. Go to your admin Cpanel and turn off "Use dot icons" -- I did point that out as a problem in my previous post :) It is trying to join the post table twice. You'll have to write an exception to check if dotqueries is turned on and if it is, change the join again.

I don't use the dots since I didn't think the join was worth it.. but for me, the join is worth it for the preview.


All times are GMT. The time now is 10:25 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01122 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete