The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Details »» | |||||||||||||||||||||||||
The search function is wicked-fast, but I wanted users to be able to see the number of times the resulting message threads have been viewed, too.
Then I wanted them to be able to sort them by the number of times viewed, so that a user can quickly spot the most popular threads in the search results. Plus I decided I wanted users to be able to sort based on the name of the forum in which a search result appears, so that somebody interested in particular forums could scan down the results page and get to the clump of messages he or she is interested in. These features come in handy especially when users are given the ability to call up all theads that are new or changed within the past X days (in addition to the "since your last visit" and "today's new or changed messages" views). (See that hack at http://www.vbulletin.com/forum/showt...p?postid=23139 ) For example, a user can fetch all messages that are new or changed in the past 30 days, then sort 'em by the number of times viewed. This shows which message threads have been the most popular lately. <b>Changes needed</b> In <b>search.php</b>: ------------------------------------------------------------ OLD: echo standardredirect($bbtitle,gettemplate("redirect_se arch",0),"search.php?query=$query&forumchoice=$for umchoice&booleanand=$booleanand&searchin=$searchin &searchdate=$searchdate&searchuser=$searchuser&exa ctname=$exactname&action=dosearch&getdaily=$getdai ly&pagenum=$pagenum"); NEW: echo standardredirect($bbtitle,gettemplate("redirect_se arch",0),"search.php?query=$query&forumchoice=$for umchoice&booleanand=$booleanand&searchin=$searchin &searchdate=$searchdate&searchuser=$searchuser&exa ctname=$exactname&action=dosearch&getdaily=$getdai ly&sortbyviews=$sortbyviews&sortbyforum=$sortbyfor um&pagenum=$pagenum"); ------------------------------------------------------------ OLD: $searchresults=$DB_site->query("SELECT DISTINCT threadid, lastpost FROM thread WHERE visible=1 $checkforum $subjectonly $checkuser $checkdate $combinedwords ORDER BY lastpost DESC"); NEW: if (isset($sortbyviews)==0 or $sortbyviews=="no") { // sortbyviews not "yes" if (isset($sortbyforum)==0 or $sortbyforum=="no") { // sortbyforum not "yes" $searchresults=$DB_site->query("SELECT DISTINCT threadid, lastpost FROM thread WHERE visible=1 $checkforum $subjectonly $checkuser $checkdate $combinedwords ORDER BY lastpost DESC"); } else { // sortbyforum is "yes" (actually, anything besides "no" or blank) $searchresults=$DB_site->query("SELECT DISTINCT thread.threadid, thread.lastpost FROM thread,forum WHERE visible=1 AND forum.forumid=thread.forumid $checkforum $subjectonly $checkuser $checkdate $combinedwords ORDER BY forum.title ASC"); } } else { // sortbyviews is "yes" (actually, anything besides "no" or blank) $searchresults=$DB_site->query("SELECT DISTINCT threadid, lastpost FROM thread WHERE visible=1 $checkforum $subjectonly $checkuser $checkdate $combinedwords ORDER BY views DESC"); } ------------------------------------------------------------ OLD: $threadinfo=$DB_site->query_first("SELECT title,postusername,dateline,lastposter,postusernam e,replycount FROM thread WHERE threadid=$searchresult[threadid]"); NEW: $threadinfo=$DB_site->query_first("SELECT title,postusername,dateline,lastposter,postusernam e,replycount,views FROM thread WHERE threadid=$searchresult[threadid]"); ------------------------------------------------------------ OLD: $nextpagelink="<a href=\"search.php?query=".urlencode($query)."&getd aily=$getdaily&forumchoice=$forumchoice&searchin=$ searchin&searchdateline=$searchdateline&searchdate =$searchdate&booleanand=$booleanand&getdaily=$getd aily&searchuser=".urlencode($searchuser)."&exactna me=$exactname&action=simplesearch&pagenum=".($page num+1)."\">[Next Page]</a>"; NEW: $nextpagelink="<a href=\"search.php?query=".urlencode($query)."&getd aily=$getdaily&forumchoice=$forumchoice&searchin=$ searchin&searchdateline=$searchdateline&searchdate =$searchdate&booleanand=$booleanand&getdaily=$getd aily&searchuser=".urlencode($searchuser)."&exactna me=$exactname&action=simplesearch&sortbyviews=$sor tbyviews&sortbyforum=$sortbyforum&pagenum=".($page num+1)."\">[Next Page]</a>"; ------------------------------------------------------------ OLD: } else { $nextpagelink=""; } NEW: } else { $nextpagelink=""; } $sortbyviewslink="<a href=\"search.php?query=".urlencode($query)."&getd aily=$getdaily&forumchoice=$forumchoice&searchin=$ searchin&searchdateline=$searchdateline&searchdate =$searchdate&booleanand=$booleanand&getdaily=$getd aily&searchuser=".urlencode($searchuser)."&exactna me=$exactname&action=simplesearch&sortbyviews=yes& sortbyforum=no&pagenum=$pagenum"."\">Total Views</a>"; $sortbydatelink="<a href=\"search.php?query=".urlencode($query)."&getd aily=$getdaily&forumchoice=$forumchoice&searchin=$ searchin&searchdateline=$searchdateline&searchdate =$searchdate&booleanand=$booleanand&getdaily=$getd aily&searchuser=".urlencode($searchuser)."&exactna me=$exactname&action=simplesearch&sortbyviews=no&s ortbyforum=no&pagenum=$pagenum"."\">Newest Message<br>in Thread</a>"; $sortbyforumlink="<a href=\"search.php?query=".urlencode($query)."&getd aily=$getdaily&forumchoice=$forumchoice&searchin=$ searchin&searchdateline=$searchdateline&searchdate =$searchdate&booleanand=$booleanand&getdaily=$getd aily&searchuser=".urlencode($searchuser)."&exactna me=$exactname&action=simplesearch&sortbyviews=no&s ortbyforum=yes&pagenum=$pagenum"."\">Forum (Message Board)</a>"; ------------------------------------------------------------ Then modify your searchresults template -- find the table that contains the table headings, and change it read this way (to accommodate the new Views view and to reflect the new, clickable headings): <table border=0 cellspacing=1 cellpadding=4 width=100%> <TR bgcolor="#113274"> <TD align="center"> <smallfont COLOR="#FFFFFF"><B>Message Thread</B></smallfont> </TD> <TD align="center"> <smallfont COLOR="#FFFFFF"><B>Started By</B></smallfont> </TD> <TD align="center"> <smallfont COLOR="#FFFFFF"><B>Reply<br>Messages</B></smallfont> </TD> <TD align="center"> <smallfont COLOR="#FFFFFF"><B>$sortbyviewslink</B> </smallfont> </TD> <TD NOWRAP align="center"> <smallfont COLOR="#FFFFFF"><B>$sortbydatelink</B></smallfont> </TD> <TD> <smallfont COLOR="#FFFFFF"><B>$sortbyforumlink</B></smallfont> </TD> </tr> $searchresultbits </table> ------------------------------------------------------------ Then modify your searchresultbit template to read like this: <TR> <TD bgcolor="#C3C3EB"> <normalfont><A HREF="$searchlink">$threadtitle</A></normalfont> </TD> <TD bgcolor="#AAAAE6"> <normalfont><a href="member.php?action=getinfo&username=$posterur l" target=_blank">$poster</a></normalfont> </TD> <TD bgcolor="#C3C3EB" align="MIDDLE"> <normalfont>$replycount</normalfont> </TD> <TD bgcolor="#C3C3EB" align="MIDDLE"> <normalfont>$views</normalfont> </TD> <TD bgcolor="#C3C3EB" NOWRAP align="MIDDLE"> <normalfont>$lastpostdate</normalfont> </TD> <TD bgcolor="#AAAAE6"> <normalfont><a href="forumdisplay.php?forumid=$forumid">$forumtit le</a></normalfont> </TD> </tr> ----------------------------------------------------------- Demo is at http://benefitsboards.net/search.php3 I tried to make $sortbydatelink and $sortbyviewslink and $sortbyforumlink into new templates, but I couldn't seem to get that to work when I dropped the $sortbydatelink template into my searchresults template (for example) -- so I hardcoded these into search.php as shown above. Maybe somebody could tell me why those new templates wouldn't work when referred to as $newtemplatename in my searchresults template. Enjoy! Show Your Support
|
Comments |
#2
|
|||
|
|||
For Example Where you have:
Code:
$sortbyviewslink="<a href=\"search.php?query=".urlencode($query)."&getdaily=$getdaily&forumchoice=$forumchoice&searchin=$searchin&searchdateline=$searchdateline&searchdate=$searchdate&booleanand=$booleanand&getdaily=$getdaily&searchuser=".urlencode($searchuser)."&exactname=$exactname&action=simplesearch&sortbyviews=yes&sortbyforum=no&pagenum=$pagenum"."\">Total Views</a>"; $sortbydatelink="<a href=\"search.php?query=".urlencode($query)."&getdaily=$getdaily&forumchoice=$forumchoice&searchin=$searchin&searchdateline=$searchdateline&searchdate=$searchdate&booleanand=$booleanand&getdaily=$getdaily&searchuser=".urlencode($searchuser)."&exactname=$exactname&action=simplesearch&sortbyviews=no&sortbyforum=no&pagenum=$pagenum"."\">Newest Message<br>in Thread</a>"; $sortbyforumlink="<a href=\"search.php?query=".urlencode($query)."&getdaily=$getdaily&forumchoice=$forumchoice&searchin=$searchin&searchdateline=$searchdateline&searchdate=$searchdate&booleanand=$booleanand&getdaily=$getdaily&searchuser=".urlencode($searchuser)."&exactname=$exactname&action=simplesearch&sortbyviews=no&sortbyforum=yes&pagenum=$pagenum"."\">Forum (Message Board)</a>"; Code:
eval("\$sortbydatelink.= \"".gettemplate("sortbydatelink")."\";"); eval("\$sortbyviewslink.= \"".gettemplate("sortbyviewslink")."\";"); eval("\$sortbyforumlink.= \"".gettemplate("sortbyforumlink")."\";"); Code:
<a href=\"search.php?query=".urlencode($query)."&getdaily=$getdaily&forumchoice=$forumchoice&searchin=$searchin&searchdateline=$searchdateline&searchdate=$searchdate&booleanand=$booleanand&getdaily=$getdaily&searchuser=".urlencode($searchuser)."&exactname=$exactname&action=simplesearch&sortbyviews=yes&sortbyforum=no&pagenum=$pagenum"."\">Total Views</a> [Edited by rangersfan on 07-26-2000 at 12:58 AM] |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|