PDA

View Full Version : subject of last post???


chipheodeptrai
03-27-2002, 03:45 AM
Hi there

Im looking for subject of last post, but i cant search it, please help me i can where do i get thread???

the same attachment

thanks for your help :chinese:

yasunari
03-28-2002, 11:08 AM
I have make some changes of this hack,
Thanks for Firefly's idea. It's work better now.. I have test this new ver on my board. http://www.kelvinlo.net/vbb/

Before --> 88 queries
Now --> 33 queries


Step 1: Change index.php & forumdisplay.php

Find this code in BOTH files:

// prepare template vars
if (!$showforumdescription) {
$forum['description']='';
}


Add the follow code after this:

$threadtitle= $DB_site->query_first("SELECT threadid,title FROM thread WHERE forumid=$forum[forumid] order by lastpost DESC");
$forum['thread']=$threadtitle[title];
$forum['threadid']=$threadtitle[threadid];

$lastposttitle=$threadtitle[title];
$lastposttitle_all = $lastposttitle;
if (strlen($lastposttitle) > 30) {
$lastposttitle = substr($lastposttitle,0,28);
$lastposttitle .= "...";
}



Change the templates forumhome_lastpostby:

found this code:

by <a href="member.php?s=$session[sessionhash]&action=getinfo&find=lastposter&forumid=$forum[forumid]"><b>$forum[lastposter]</b></a>


Add this after it:

<br><b><a href="showthread.php?s=$session[sessionhash]&threadid=$forum[threadid]" title="$lastposttitle_all">$lastposttitle</a></b>

Admin
03-28-2002, 02:35 PM
Just thought you should know this will add *4* queries for every forum you have...

yasunari
03-29-2002, 12:23 AM
heh, yes it make more queries..

It specialy takes heavy queries on the index..
Page generated in 0.7211850 seconds (15.79% PHP - 84.21% MySQL) with 87 queries.

Admin
03-29-2002, 06:36 AM
Then why use it? And you have 4 queries there that can be done with only one:
$lastpostinfo = $DB_site->query_first("
SELECT u.userid,t.lastposter AS username,t.title,t.threadid
FROM thread t
LEFT JOIN user u ON t.lastposter=u.username
WHERE t.forumid=$forum[forumid] ORDER BY t.lastpost DESC
");
And you don't even need userid, lastposter and threadid as that's already handled by vB.

yasunari
03-29-2002, 08:14 AM
Thanks Firefly, I have make a little change of that code now.. wish it work better. I am going to test it on my board tonight, I have this hack work on my test board :squareeyed:

Current know problem: It will show the thread title from the private forums if you turn your private forum visible to others.

Admin
03-29-2002, 11:30 AM
PPN already released a hack that does this with no extra queries, it just stores the last thread title in the forum table.

yasunari
03-29-2002, 12:27 PM
Can you post the link here?

Admin
03-29-2002, 12:29 PM
Look at PPN's profile, you can find it there.

yasunari
03-29-2002, 12:32 PM
Thanks! I got it now :classic: