Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 07-26-2000 Last Update: Never Installs: 0
 
No support by the author.

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

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-26-2000, 03:56 AM
Guest
 
Posts: n/a
Default

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>";
You need to put:

Code:
eval("\$sortbydatelink.= \"".gettemplate("sortbydatelink")."\";"); 
eval("\$sortbyviewslink.= \"".gettemplate("sortbyviewslink")."\";"); 
eval("\$sortbyforumlink.= \"".gettemplate("sortbyforumlink")."\";");
These templates will have access to all variables in the code before they are called so you would put this in the "sortbyviewslink" template

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>
Follow this example for the other templates

[Edited by rangersfan on 07-26-2000 at 12:58 AM]
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:47 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.03450 seconds
  • Memory Usage 2,217KB
  • Queries Executed 15 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (1)postbit
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete