1 頁 (共 1 頁)

[問題]請問可否自由選擇排序的方法?

發表於 : 2002-08-05 13:03
joycat
[問題]請問可否自由選擇排序的方法?
例如, 以主題排序, 以發表人排序...
而不是像現在一樣, 只能用日期時間排序呢?

發表於 : 2002-08-06 16:51
joycat
真的只能用日期排序嗎?
還是可以改成用主題或其他條件排序呢?

或是有MOD可以做到這?
/please

發表於 : 2003-06-01 01:46
wi777
小弟不知你要問的是不是 依 依文章標題 張貼時間 最近張貼 及 依作者

請點擊後進入討論區最下方觀看
小弟亂答的

直接下載
##############################################################
## MOD Title: Topic display order
## MOD Author: Ptirhiik < admin@rpgnet-fr.com > (Ptirhiik) http://www.rpgnet-fr.com
## MOD Description:
## This mod allows your users to sort the topics in a forum
## by author, topic_title, topic time, and last reply time (default sort),
## ascending or descending
## MOD Version: 1.0.0
##
## Installation Level: easy
## Installation Time: 5 Minutes
## Files To Edit:
## viewforum.php
## templates/subSilver/viewforum_body.tpl
##
\n## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
## Author Notes:
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
#
#-----[ REPLACE WITH ]----------------------------------------
#
//
// Grab all the basic data (all topics except announcements)
// for this forum
//

//-- mod : topic display order ---------------------------------------------------------------------
//-- add
//
// Sort def
$sort_list_desc = $lang['Sort_by'];
$sort_list_parm = array(
't.topic_last_post_id' => $lang['Last_Post'],
't.topic_title' => $lang['Sort_Topic_Title'],
't.topic_time' => $lang['Sort_Time'],
'u.username' => $lang['Sort_Author'],
);
$sort_method = 't.topic_last_post_id';
if ( isset($HTTP_GET_VARS['sort']) || isset($HTTP_POST_VARS['sort']) )
{
$sort_method = isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : $HTTP_POST_VARS['sort'];
}
//
// set the sort menu
$sort_list = '<select name="sort">';
while ( list($key, $value) = each($sort_list_parm) )
{
$selected = ($sort_method == $key) ? ' selected="selected"' : '';
$sort_list .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
}
$sort_list .= '</select>';
//
// Order def
$order_list_desc = $lang['Order'];
$order_list_parm = array('ASC' => $lang['Sort_Ascending'], 'DESC' => $lang['Sort_Descending']);
$sort_order = 'DESC';
if (in_array( $forum_id, array(1,2,3,4,5,6,7,8,9,10,11,12,13) ) ) $sort_order = 'ASC';
if ( isset($HTTP_GET_VARS['order']) || isset($HTTP_POST_VARS['order']) )
{
$sort_order = isset($HTTP_GET_VARS['order']) ? $HTTP_GET_VARS['order'] : $HTTP_POST_VARS['order'];
}
//
// set the order menu
$order_list = '<select name="order">';
while ( list($key, $value) = each($order_list_parm) )
{
$selected = ($sort_order == $key) ? ' selected="selected"' : '';
$order_list .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
}
$order_list .= '</select>';
//
// read topics
//-- delete
// $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
// FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
// WHERE t.forum_id = $forum_id
// AND t.topic_poster = u.user_id
// AND p.post_id = t.topic_first_post_id
// AND p2.post_id = t.topic_last_post_id
// AND u2.user_id = p2.poster_id
// AND t.topic_type <> " . POST_ANNOUNCE . "
// $limit_topics_time
// ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
// LIMIT $start, ".$board_config['topics_per_page'];
//-- add
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
ORDER BY t.topic_type DESC, $sort_method $sort_order
LIMIT $start, ".$board_config['topics_per_page'];
//-- fin mod : topic display order -----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
make_jumpbox('viewforum.'.$phpEx);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic display order ---------------------------------------------------------------------
//-- add
$template->assign_vars(array(
'L_SORT_METHOD' => $sort_list_desc,
'S_SORT_METHOD' => $sort_list,
'L_ORDER' => $order_list_desc,
'S_ORDER' => $order_list,
)
);
//-- fin mod : topic display order -----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
#
#-----[ REPLACE WITH ]----------------------------------------
#
//-- mod : topic display order ---------------------------------------------------------------------
//-- delete
// 'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
//-- add
'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days".( ($forum_row['forum_type'] == FORUM_TYPE_TOPIC_SORT_TITLE) ? "&sort=$sort_method&order=$sort_order" : "" ), $topics_count, $board_config['topics_per_page'], $start),
//-- fin mod : topic display order -----------------------------------------------------------------

#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
{L_DISPLAY_TOPICS}:
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : topic display order -->
<!-- add -->
{L_SORT_METHOD}: {S_SORT_METHOD}  
{L_ORDER}: {S_ORDER}  
<!-- fin mod : topic display order -->
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM