09-07-2000, 11:38 PM
Hi,
Here is my first hack. (that doesn't necessarily mean it will not work) :D
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:
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
Then replace it with:
if($sortbyreply=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,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,postuserna me,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,postuserna me,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,postuserna me,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,postuserna me,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:
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):
<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. :)
Here is my first hack. (that doesn't necessarily mean it will not work) :D
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:
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
Then replace it with:
if($sortbyreply=="yes"){
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,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,postuserna me,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,postuserna me,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,postuserna me,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,postuserna me,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:
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):
<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. :)