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: 09-07-2000 Last Update: Never Installs: 0
 
No support by the author.

Hi,

Here is my first hack. (that doesn't necessarily mean it will not work)

It is partially based on Dave Baker hack here:
http://vbulletin.com/forum/showthread.php?threadid=1853


This hack will simply enable users to sort threads by four additional ways:
1- Number of replies.
2- Number of viewers
3- Alphabetical order of poster names
4- Threadid , this will make threads ordered by the newest topic regardless of the last reply date.



ok, and now what you need to change


look for this line in forumdiplay.php:
Code:
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
Then replace it with:
Code:
if($sortbyreply=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY replycount DESC LIMIT $limitlower,$perpage"); 
}elseif($sortbyviews=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY views DESC LIMIT $limitlower,$perpage"); 
} elseif($sortbyuser=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY postusername asc LIMIT $limitlower,$perpage"); 
}elseif($sortbytitle=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY threadid DESC LIMIT $limitlower,$perpage"); 
}else {
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage"); 
}


In the same file above (forumdisplay.php) add whats in bold:

Code:
while ($curpage++<$totalpages) {

    if (($curpage<$pagenumber-$pagenavpages or $curpage>$pagenumber+$pagenavpages) and $pagenavpages!=0) {
      if ($curpage==1) {
        $pagenav.=" <a href=\"forumdisplay.php?forumid=$forumid&daysprune=$daysprune&pagenumber=$curpage&sortbyviews=$sortbyviews&sortbytitle=$sortbytitle&sortbyuser=$sortbyuser&sortbyreply=$sortbyreply".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><< First Page</a> ... ";
      }
      if ($curpage==$totalpages) {
        $pagenav.=" ... <a href=\"forumdisplay.php?forumid=$forumid&daysprune=$daysprune&pagenumber=$curpage&sortbyviews=$sortbyviews&sortbytitle=$sortbytitle&sortbyuser=$sortbyuser&sortbyreply=$sortbyreply".iif($perpage==$maxposts,"","&perpage=$perpage")."\">Last Page >></a>";
      }
    } else {
      if ($curpage==$pagenumber) {
        $pagenav.=" $curpage";
      } else {
        $pagenav.=" <a href=\"forumdisplay.php?forumid=$forumid&daysprune=$daysprune&pagenumber=$curpage&sortbyviews=$sortbyviews&sortbytitle=$sortbytitle&sortbyuser=$sortbyuser&sortbyreply=$sortbyreply".iif($perpage==$maxposts,"","&perpage=$perpage")."\">$curpage</a>";
      }
    }
  }

And finally in forumdisplay template add whats in Bold (again):
Code:

<table border="0" cellpadding="4" cellspacing="1" width="100%"> 
<tr bgcolor="#113274"> 
<td colspan="2" align="center" width="60%"> 
<a href="forumdisplay.php?forumid=$forumid&daysprune=$daysprune&sortbytitle=yes">
<FONT face="verdana,arial,helvetica" size="1"  color="#FFFFFF"><B>
Name of Thread (Topic)</B></font>
</a>
</td> 
<td align="center" width="10%">
<a href="forumdisplay.php?forumid=$forumid&daysprune=$daysprune&sortbyuser=yes">
<FONT face="verdana,arial,helvetica" size="1"  color="#FFFFFF"><B>Started By</B></font>
</a> 
</td> 
<td align="center" width="5%">
<a href="forumdisplay.php?forumid=$forumid&daysprune=$daysprune&sortbyreply=yes">
<FONT face="verdana,arial,helvetica" size="1"  color="#FFFFFF"><B>Reply<br>Messages</B></font>
</a> 
</td> 
<td align="center" width="5%">
<a href="forumdisplay.php?forumid=$forumid&daysprune=$daysprune&sortbyviews=yes">
<FONT face="verdana,arial,helvetica" size="1"  color="#FFFFFF"><B>
Total<br>Views</B></font> 
</a>
</td> 
<td align="center" width="20%"> 
<a href="forumdisplay.php?forumid=$forumid&daysprune=$daysprune">
<FONT face="verdana,arial,helvetica" size="1"  color="#FFFFFF"><B>Newest Message<br>In Thread</B></font> 
</a>
</td></tr>

Thats it. Hope you like it.

Show Your Support

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

Comments
  #2  
Old 09-07-2000, 11:48 PM
Guest
 
Posts: n/a
Default

that's great! do you have a working demo?
Reply With Quote
  #3  
Old 09-08-2000, 04:07 AM
Guest
 
Posts: n/a
Default

Hello,

I tried SOrt by Title...it does not work...it brings back some order...just not alphabetical...

Everything else works..

One Thing. It does not sort by Last post...it just brings you to the regular forumdisplay. Is that on purpose or did you forget to add code.

Question: Does this hack have any resource or efficiency issues with mysql or the server on high usage?

Great Hack. Thanks.

[Edited by VirtueTech on 09-08-2000 at 01:14 AM]
Reply With Quote
  #4  
Old 09-08-2000, 04:32 AM
Guest
 
Posts: n/a
Default

Conan,

You can see VirtueTech's forum. Mine is not in English so it might be hard to see whats going on.



VirtueTech,

As I said, sort by title does NOT sort treads alphabeticly (cause I thought it might be useless). It sorts them by the date of the first post in that thread (the main post). You can check'em out yourself and see the dates. If you want to make it sort alphabeticly, just replace.

Code:
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY threadid DESC LIMIT $limitlower,$perpage");
with
Code:
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY title DESC LIMIT $limitlower,$perpage");

Regular forumdisplay actually does sort threads by last post I added it so that people can get back to normal sorting.

I cannot answer your last question cause I'm not that experinced. One of the guys might have an answer.





[Edited by Essam on 09-08-2000 at 01:37 AM]
Reply With Quote
  #5  
Old 09-08-2000, 04:39 AM
Guest
 
Posts: n/a
Default

Hello,

Sorry in my excited rave I forgot to read the part about threadid...Lots of users are going to get confused when they see the Threads sort not alphabetcal...same with Last Post sort.

Maybe I'm wrong.
Reply With Quote
  #6  
Old 09-08-2000, 04:52 AM
Guest
 
Posts: n/a
Default

What would be really cool is if you could sort by ascending then click on it again and it sorts by descending.

Then we would need a down arrow and up arrow...for the two...like Outlook does its sorting.
Reply With Quote
  #7  
Old 09-08-2000, 07:56 AM
Guest
 
Posts: n/a
Default

It would be cool if you make it so that if you click it sorts ascending and if you click again it sorts descending

One remark though:

The following code can be much shorter:

Code:
if($sortbyreply=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY replycount DESC LIMIT $limitlower,$perpage"); 
}elseif($sortbyviews=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY views DESC LIMIT $limitlower,$perpage"); 
} elseif($sortbyuser=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY postusername asc LIMIT $limitlower,$perpage"); 
}elseif($sortbytitle=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY threadid DESC LIMIT $limitlower,$perpage"); 
}else {
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage"); 
}
better:

Code:
if(empty($orderField))
$orderField = "lastpost";
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY $orderField DESC LIMIT $limitlower,$perpage");
And then make orderfield the variable to use within the links, example:

forumdisplay.php?forumid=$forumid&daysprune=$daysp rune&orderField=lastpost

or something like that. This way you don't have to alter the code if you want another field against to order, just make a link with orderField="anyFieldYouWant" and it works (provided that the field exists within the table)

[Edited by Mas*Mind on 09-08-2000 at 04:58 AM]
Reply With Quote
  #8  
Old 09-08-2000, 08:27 AM
Guest
 
Posts: n/a
Default

Well not all the sorts are descending ... your code would make it that way But a good idea!

A good example of one click is ascending and the next click is descending is at a medical site I'm working on:

http://www.medinfolinks.com/cgi-loca...etail.cgi?ID=5

Also notice how the Sort by Arrow graphics changes on each column.

This would be a great feature to have.
Reply With Quote
  #9  
Old 09-08-2000, 06:59 PM
Guest
 
Posts: n/a
Default

Does this hack cause any server load issues with mysql or just the same as a regular forum display process?
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 10:38 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.04030 seconds
  • Memory Usage 2,271KB
  • Queries Executed 22 (?)
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
  • (8)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)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