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-03-2002 06:03 PM

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 ;)

Overgrow 03-03-2002 07:19 PM

>>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~

N!ck 03-03-2002 08:42 PM

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/


Overgrow 03-03-2002 08:57 PM

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.

Overgrow 03-03-2002 08:58 PM

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
    "
); 


Freddie Bingham 03-03-2002 09:26 PM

'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.

Freddie Bingham 03-03-2002 09:28 PM

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).

N!ck 03-03-2002 10:21 PM

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

N!ck 03-04-2002 02:42 AM

update released!

thread previews on searches will be in the next update

Erwin 03-04-2002 08:38 AM

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... :)


All times are GMT. The time now is 07:23 PM.

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.01369 seconds
  • Memory Usage 1,767KB
  • 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_code_printable
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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