Version: 1.00, by Erwin
Developer Last Online: May 2013
Version: 2.3.x
Rating:
Released: 10-28-2002
Last Update: Never
Installs: 82
No support by the author.
Search Thread - by Erwin Loh
-----------------------------
This hack will add a "Search This Thread" search box at the bottom of threads (similar to the "Search This Forum" search box at the bottom of Forum Display).
Should be useful for loooooooooooooong threads, especially for a forum like this one.
Demo
-------
This hack is installed here at vB.org - just use the Search This Thread box at the bottom right hand corner of this page.
Features
-----------
1. Only posts from the thread will be searched.
2. Uses that standard searchindex table.
3. Uses the same vB search algorithms.
4. This will add NO extra queries to your forum.
5. Uses the standard search and forum permissions set by you.
Installation
------------
1. Running 1 database query
2. Making 2 changes to showthread.php
3. Making 6 changes to search.php
4. Making 1 change to template "showthread"
5. Adding a new template "showthread_searchthread"
Enjoy!
Please click install if you want updates to this hack!
Dr. Erwin Loh
I've updated the installation text file to make things clearer, and made the search box visible to guests as well.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Mmm... that's strange. Make sure you follow the installation instruction exactly - they can be tricky - don't double up on code - some of the code are meant to replace, some are to be added. I assume you ran the db query as well.
Okay, the code in my search.php for step 4 is as follows:
PHP Code:
$getpostids=$DB_site->query("
SELECT
post.postid, thread.visible".
iif(strlen(strpos(" $orderbysql","posttext")),",IF(post.title='',LEFT(post.pagetext,50),post.title) AS posttext","").
iif(strlen(strpos(" $orderbysql","usrname")),",IF(post.userid=0,post.username,user.username) AS usrname","").
"
FROM
post".
iif(strlen(strpos($search[query],"searchindex")),",searchindex","").
iif(strlen(strpos(" $orderbysql","thread.")) or strlen(strpos($search[query],"thread.")) or strlen(strpos($orderbysql,"forum.")) or strlen(strpos($search[query],"forum."))," LEFT JOIN thread ON thread.threadid=post.threadid ","").
iif(strlen(strpos(" $orderbysql","forum.")) or strlen(strpos($search[query],"forum."))," LEFT JOIN forum ON thread.forumid=forum.forumid ","").
iif(strlen(strpos(" $orderbysql","usrname"))," LEFT JOIN user ON (post.userid=user.userid) ","").
"
WHERE
post.visible=1 AND thread.visible=1 AND $searchthreadquery$newpostsql$search[query] ORDER BY
$orderbysql LIMIT ".($limitlower-1).",$perpage ");
and for step 5 it's:
PHP Code:
$sql="
SELECT
post.postid,post.title AS posttitle,post.dateline AS postdateline,post.userid AS postuserid,post.iconid AS posticonid,LEFT(post.pagetext,250) AS pagetext,
thread.threadid,thread.title AS threadtitle,thread.iconid AS threadiconid,thread.replycount,thread.views,thread.pollid,thread.open,thread.lastpost,
forum.forumid,forum.title AS forumtitle,forum.allowicons,user.username,
IF(post.title='',LEFT(post.pagetext,50),post.title) AS posttext,
IF(post.userid=0,post.username,user.username) AS usrname,
posticon.iconpath AS posticonpath,posticon.title AS posticontitle,
threadicon.iconpath AS threadiconpath,threadicon.title AS threadicontitle
FROM
post".iif(strpos($search[query],"searchindex")>0,",searchindex","").",thread
LEFT JOIN forum ON forum.forumid=thread.forumid
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN icon AS threadicon ON thread.iconid=threadicon.iconid
LEFT JOIN icon AS posticon ON post.iconid=posticon.iconid
WHERE
$postids AND $searchthreadquery thread.threadid=post.threadid
ORDER BY
$orderbysql";
That looks right. And you REPLACED the relevant sections in your search.php. Make sure you are replacing the correct sections - there are 2 similar sections, one for "threadonly" and one for "showposts" - replace the SECOND lot, not the first lot in search.php - ie. the exact piece of code you are meant to find in the instructions (one reason why I ask to find a huge chunk of code to replace - there are 2 similar sections).
Originally posted by Erwin That looks right. And you REPLACED the relevant sections in your search.php. Make sure you are replacing the correct sections - there are 2 similar sections, one for "threadonly" and one for "showposts" - replace the SECOND lot, not the first lot in search.php - ie. the exact piece of code you are meant to find in the instructions (one reason why I ask to find a huge chunk of code to replace - there are 2 similar sections).
Yep, that's what I did, and it's not working. I've double-checked the hack installation, and I've followed your instructions to the letter, but I'm still getting that DB error.
I've updated the installation text file to make the instructions clearer and easier.
Also, I changed the way the code is like in showthread.php to make the search box viewable by guests.
However, the search box will still follow search and forum permissions. If guests are not allowed to search, they won't be able to. Private forum permissions will be intact as well.