[問題] Top5 for Integrated Toplist 的三種 Sortby

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

[問題] Top5 for Integrated Toplist 的三種 Sortby

文章 davidhuang »

想請教各位高手,
小弟的討論區有裝 Top5 for Integrated Toplist , 預設 Sortby 是秀 topic_last_post_id , 但我想三種 Sortby 都各秀 10 筆資料(不同區塊)該如何做呢?

// Order by
// topic_last_post_id (Default)
// topic_replies
// topic_views

請各位高手幫忙, 感謝您!!!

這個問題的外掛位置 : Top5 for Integrated Toplist
http://phpbb-tw.net/phpbb/viewtopic.php?t=40021

●架設主機作業系統:Linux (Fedoara Core 6)
●您的上網方式:Hinet ADSL 12M/1M
●您的 phpBB2 版本:phpBB 2.0.21
●您的 domain(網域名稱) :http://pspwave.eland.idv.tw
●您的 phpBB2 連結網址:http://pspwave.eland.idv.tw
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

他和這隻官方認證外掛 (Top5 for Integrated Toplist), 都是由 adv top5 抽取其中一部分改良而來.
http://phpbb-tw.net/phpbb/viewtopic.php?t=31959

建議您:
參考以下主題
1. TOP5 主題 for phpBB 2.0.0
http://phpbb-tw.net/phpbb/viewtopic.php?t=5044
2. http://phpbb-tw.net/phpbb/viewtopic.php?t=39219
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈捕手 寫:他和這隻官方認證外掛 (Top5 for Integrated Toplist), 都是由 adv top5 抽取其中一部分改良而來.
http://phpbb-tw.net/phpbb/viewtopic.php?t=31959

建議您:
參考以下主題
1. TOP5 主題 for phpBB 2.0.0
http://phpbb-tw.net/phpbb/viewtopic.php?t=5044
2. http://phpbb-tw.net/phpbb/viewtopic.php?t=39219
心靈兄:

以上兩個 Top5 都試裝, 但都沒有 Integrated Toplist 好用(最貼進 Style), 只是想將三種不同的 Order By Show 出來, 無奈學藝不精阿........ :-D
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:
心靈捕手 寫:他和這隻官方認證外掛 (Top5 for Integrated Toplist), 都是由 adv top5 抽取其中一部分改良而來.
http://phpbb-tw.net/phpbb/viewtopic.php?t=31959

建議您:
參考以下主題
1. TOP5 主題 for phpBB 2.0.0
http://phpbb-tw.net/phpbb/viewtopic.php?t=5044
2. http://phpbb-tw.net/phpbb/viewtopic.php?t=39219
心靈兄:

以上兩個 Top5 都試裝, 但都沒有 Integrated Toplist 好用(最貼進 Style), 只是想將三種不同的 Order By Show 出來, 無奈學藝不精阿........ :-D
發表了一個外掛, 可以參考看看:
http://phpbb-tw.net/phpbb/viewtopic.php?p=255883#255883
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈捕手 寫:
davidhuang 寫:
心靈捕手 寫:他和這隻官方認證外掛 (Top5 for Integrated Toplist), 都是由 adv top5 抽取其中一部分改良而來.
http://phpbb-tw.net/phpbb/viewtopic.php?t=31959

建議您:
參考以下主題
1. TOP5 主題 for phpBB 2.0.0
http://phpbb-tw.net/phpbb/viewtopic.php?t=5044
2. http://phpbb-tw.net/phpbb/viewtopic.php?t=39219
心靈兄:

以上兩個 Top5 都試裝, 但都沒有 Integrated Toplist 好用(最貼進 Style), 只是想將三種不同的 Order By Show 出來, 無奈學藝不精阿........ :-D
發表了一個外掛, 可以參考看看:
http://phpbb-tw.net/phpbb/viewtopic.php?p=255883#255883
謝謝心靈兄:

但改完發現....最多回覆 & 最多觀看 的主題沒秀出來.
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:
心靈捕手 寫:
davidhuang 寫: 心靈兄:

以上兩個 Top5 都試裝, 但都沒有 Integrated Toplist 好用(最貼進 Style), 只是想將三種不同的 Order By Show 出來, 無奈學藝不精阿........ :-D
發表了一個外掛, 可以參考看看:
http://phpbb-tw.net/phpbb/viewtopic.php?p=255883#255883
謝謝心靈兄:

但改完發現....最多回覆 & 最多觀看 的主題沒秀出來.
抱歉! 寫稿時有疏漏. :oops:

以下 index.php 修改, 提供您參考:
#
#-----[ FIND ]-----
#

代碼: 選擇全部

'TOPIC' => cutStr($rows2['topic_title']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

'TOPIC2' => cutStr($rows2['topic_title']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

'TOPIC' => cutStr($rows3['topic_title']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

'TOPIC3' => cutStr($rows3['topic_title']),
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈捕手 寫:
davidhuang 寫:
心靈捕手 寫: 發表了一個外掛, 可以參考看看:
http://phpbb-tw.net/phpbb/viewtopic.php?p=255883#255883
謝謝心靈兄:

但改完發現....最多回覆 & 最多觀看 的主題沒秀出來.
抱歉! 寫稿時有疏漏. :oops:

以下 index.php 修改, 提供您參考:
#
#-----[ FIND ]-----
#

代碼: 選擇全部

'TOPIC' => cutStr($rows2['topic_title']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

'TOPIC2' => cutStr($rows2['topic_title']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

'TOPIC' => cutStr($rows3['topic_title']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

'TOPIC3' => cutStr($rows3['topic_title']),
快別這麼說...欠心靈兄很多, 心靈兄真的很熱心...... :-D

順便問心靈兄一個問題, 這個問題我一直爬不到文, 就是 "最新回覆" 是以最新回覆的為優先排序, 而且不是以最新發表的文章, 不知道有什麼方法可以以最新發表的文章為排序??
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:快別這麼說...欠心靈兄很多, 心靈兄真的很熱心...... :-D

順便問心靈兄一個問題, 這個問題我一直爬不到文, 就是 "最新回覆" 是以最新回覆的為優先排序, 而且不是以最新發表的文章, 不知道有什麼方法可以以最新發表的文章為排序??
若以我的認知, 則這兩者根本是指同一件事啊! :roll:
最後發表 == 最新回覆

只不過, 此外掛的 '主題' 顯示該主題 (title);
而 '最後發表' 則顯示該主題最新回覆的發表者以及文章連結.
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈捕手 寫:
davidhuang 寫:快別這麼說...欠心靈兄很多, 心靈兄真的很熱心...... :-D

順便問心靈兄一個問題, 這個問題我一直爬不到文, 就是 "最新回覆" 是以最新回覆的為優先排序, 而且不是以最新發表的文章, 不知道有什麼方法可以以最新發表的文章為排序??
若以我的認知, 則這兩者根本是指同一件事啊! :roll:
最後發表 == 最新回覆

只不過, 此外掛的 '主題' 顯示該主題 (title);
而 '最後發表' 則顯示該主題最新回覆的發表者以及文章連結.
嗯...心靈兄...是認知的問題沒錯, 對我來說第一個發表文章(也就是開文的那一位)才是最新發表, 而再回覆這篇文章的則是最新回覆, 所以我是想要以 "最新發表" 做排序...... :oops:
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:
心靈捕手 寫:
davidhuang 寫:快別這麼說...欠心靈兄很多, 心靈兄真的很熱心...... :-D

順便問心靈兄一個問題, 這個問題我一直爬不到文, 就是 "最新回覆" 是以最新回覆的為優先排序, 而且不是以最新發表的文章, 不知道有什麼方法可以以最新發表的文章為排序??
若以我的認知, 則這兩者根本是指同一件事啊! :roll:
最後發表 == 最新回覆

只不過, 此外掛的 '主題' 顯示該主題 (title);
而 '最後發表' 則顯示該主題最新回覆的發表者以及文章連結.
嗯...心靈兄...是認知的問題沒錯, 對我來說第一個發表文章(也就是開文的那一位)才是最新發表, 而再回覆這篇文章的則是最新回覆, 所以我是想要以 "最新發表" 做排序...... :oops:
呵! 呵! 您還是沒有領悟我的回覆內容. :mrgreen:

因為此外掛 '最後發表' 重點在於要 (排序) 顯示 '最新回覆' 的文章.
所以當 '最新發表' 的主題 (文章) 還沒有任何人回覆時, 自然就是以 '最新發表' 做排序.
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈兄:

我了解了....感謝....我用您的外掛也改良了一個直式的..並將Toplist 變數增加(讓Top 數可彈性修改)..希望有需要的人也可以使用.

範例: http://www.sonydslr.com.tw
代碼 寫:
##############################################################
## 外掛名稱: Better Toplist (改良的最多列表)
## 外掛作者: wang5555 < wang55.wang55@msa.hinet.net > (心靈捕手) http://wang5555.dnsfor.me/
## 外掛描述: 這個外掛, 將論壇內最後發表, 最多回覆, 以及最多觀看的主題 (最後發表者), 在首頁列表.
##
## 外掛版本: 1.0.0
##
## 安裝難度: 簡單
## 安裝時間: < 5 Minutes
## 需要編輯的檔案: 2
## index.php
## templates/subSilver/index_body.tpl
## 附加檔案: 無
## 版權聲明: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## 由於安全上的考量, 請檢查: http://phpbb-tw.net/phpbb/index.php
## 是否有此外掛的最新版本.
################################################################
## 作者留言:
##
## 1. 此外掛中心思想, 乃參考 Top5 Topics 2.1.0, 特此銘謝
## 該外掛參考連結: http://phpbb-tw.net/phpbb/viewtopic.php?t=5044
##
## 2. 此外掛乃參考 Integrated Toplist 撰寫, 特此銘謝
## 該外掛參考連結: http://phpbb-tw.net/phpbb/viewtopic.php?t=31959
##
## 3. 此外掛為了有效降低資料庫查詢的次數, 以及濃縮 index_body.tpl 版面
## 因此 /* 省略 主題發表人 查詢 */, 以及註解 // 版面名稱, 回覆, 發表人, 觀看
##
## 4. 此外掛在 phpBB 2.0.22 (utf-8) 安裝, 測試無誤
##
################################################################
## 外掛歷史:
##
## 2007-04-01 - Version 1.0.0
## - 首次發表
##
##############################################################
## 新增外掛前, 請先備份相關檔案.
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
index.php

#
#-----[ FIND ]------------------------------------------
#
//
// Find which forums are visible for this user
//
$is_auth_ary = array();
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);

#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// + Better Toplist =====
//
//
// Option of Toplist Start
//

// 主題字數長度
$MAX_STR_LEN = 180;

// 主題列表數目
$MAX_TOPICS = 10;
$MAX_TOPICS2 = 5;
$MAX_TOPICS3 = 5;

// 0 => users can see all topics including authorized issue(but they cant read the posts)
// 1 => users can see only authorized topics
$AUTH_SECRUITY = 1;

// 主題排序依據
$sortby = 'topic_last_post_id';
$sortby2 = 'topic_replies';
$sortby3 = 'topic_views';

//
// Option of Toplist End
//

function cutStr($str) {
global $MAX_STR_LEN;
$str = (mb_strlen($str, 'utf-8') > $MAX_STR_LEN) ? (mb_substr($str, 0, $MAX_STR_LEN - 3, 'utf-8') . "...") : $str;// UTF-8
return $str;
}

// Find which forums are visible for this user
$is_auth_ary_top5 = array();
$is_auth_ary_top5 = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

$auth_forum_ary_top5 = array();

// Get forum info
$sql = "SELECT forum_id FROM " . FORUMS_TABLE;

if( !$q_forums = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch forum info fail', __LINE__, __FILE__, $sql);
}

// Authorized forums info
while( $forum_row = $db->sql_fetchrow($q_forums) )
{
$forum_id1 = $forum_row['forum_id'];

if( $is_auth_ary_top5[$forum_id1]['auth_read'] == 1)
{
if(function_exists("array_push"))
{
array_push($auth_forum_ary_top5, $forum_id1);
} else {
$auth_id=count($auth_forum_ary_top5);
$auth_forum_ary_top5[$auth_id]=$forum_id1;
}
}
}

if( sizeOf($auth_forum_ary_top5) == 0 || !$AUTH_SECRUITY )
{
$auth_forums_top5 = "";
}
else
{
$auth_forums_top5 = 'AND f.forum_id IN(';

if(sizeOf($auth_forum_ary_top5) > 1)
{
$auth_forums_top5 .= implode (',', $auth_forum_ary_top5);
}
else
{
$auth_forums_top5 .= $auth_forum_ary_top5[0];
}

$auth_forums_top5 .= ')';
}

// 最後發表
// query
$sql = "SELECT t.topic_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.forum_id = f.forum_id
AND topic_moved_id = '0'
$auth_forums_top5
ORDER BY $sortby DESC LIMIT 0, $MAX_TOPICS";

if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic info fail', __LINE__, __FILE__, $sql);
}

// fetch rows
while( $rows = $db->sql_fetchrow($result) )
{
$topic_url = append_sid("viewtopic.$phpEx?t=" . $rows['topic_id']);
$forum_url = append_sid("viewforum.$phpEx?f=" . $rows['forum_id']);

$topic_poster = $rows['topic_poster'];
$topic_last_post_id = $rows['topic_last_post_id'];

// Grab topic poster and last replier data

$sql = "SELECT post_username, user_id, username
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE topic_id = '" . $rows['topic_id'] . "'
AND poster_id = user_id
ORDER BY post_id LIMIT 0, 1";

if( !$p_result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic poster fail', __LINE__, __FILE__, $sql);
}

$p_row = $db->sql_fetchrow($p_result);

$poster_name = ( $topic_poster != ANONYMOUS ) ? $p_row['username'] : ( !$p_row['post_username'] ? $lang['Guest'] : $p_row['post_username']);
$poster_url = ( $topic_poster != ANONYMOUS && !$p_row['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$topic_poster") . '">' . "$poster_name</a>") : $poster_name;

/* 省略 主題發表人 查詢 */

$sql = "SELECT post_username, user_id, username, post_time
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE post_id = '$topic_last_post_id'
AND poster_id = user_id";

if( !$r_result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic last replier fail', __LINE__, __FILE__, $sql);
}

$r_row = $db->sql_fetchrow($r_result);

$replier_id = $r_row['user_id'];
$replier_name = ( $replier_id != ANONYMOUS ) ? $r_row['username'] : ( !$r_row['post_username'] ? $lang['Guest'] : $r_row['post_username']);
$replier_url = ( $replier_id != ANONYMOUS && !$r_row['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$replier_id") . '">' . "$replier_name</a>") : $replier_name;

$last_post_url = append_sid("viewtopic.$phpEx?p=$topic_last_post_id#$topic_last_post_id");

$template->assign_block_vars("toprow", array(
'FORUM_NAME' => $rows['forum_name'],
'FORUM_URL' => $forum_url,
'TOPIC' => cutStr($rows['topic_title']),
'TOPIC_URL' => $topic_url,
'TOPIC_VIEWS' => $rows['topic_views'],
'TOPIC_REPLIES' => $rows['topic_replies'],
'POST_TIME' => create_date($board_config['default_dateformat'], $r_row['post_time'], $board_config['board_timezone']),
'POSTER_URL' => $poster_url,
'REPLIER_URL' => $replier_url,
'LAST_POST_URL' => $last_post_url

));
}

// 最多回覆
// query
$sql2 = "SELECT t.topic_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.forum_id = f.forum_id
AND topic_moved_id = '0'
$auth_forums_top5
ORDER BY $sortby2 DESC LIMIT 0, $MAX_TOPICS2";

if( !$result2 = $db->sql_query($sql2) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic info fail', __LINE__, __FILE__, $sql2);
}

// fetch rows
while( $rows2 = $db->sql_fetchrow($result2) )
{
$topic_url2 = append_sid("viewtopic.$phpEx?t=" . $rows2['topic_id']);
$forum_url2 = append_sid("viewforum.$phpEx?f=" . $rows2['forum_id']);

$topic_poster2 = $rows2['topic_poster'];
$topic_last_post_id2 = $rows2['topic_last_post_id'];

// Grab topic poster and last replier data

$sql2 = "SELECT post_username, user_id, username
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE topic_id = '" . $rows2['topic_id'] . "'
AND poster_id = user_id
ORDER BY post_id LIMIT 0, 1";

if( !$p_result2 = $db->sql_query($sql2) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic poster fail', __LINE__, __FILE__, $sql2);
}

$p_row2 = $db->sql_fetchrow($p_result2);

$poster_name2 = ( $topic_poster2 != ANONYMOUS ) ? $p_row2['username'] : ( !$p_row2['post_username'] ? $lang['Guest'] : $p_row2['post_username']);
$poster_url2 = ( $topic_poster2 != ANONYMOUS && !$p_row2['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$topic_poster") . '">' . "$poster_name2</a>") : $poster_name2;

/* 省略 主題發表人 查詢 */

$sql2 = "SELECT post_username, user_id, username, post_time
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE post_id = '$topic_last_post_id2'
AND poster_id = user_id";

if( !$r_result2 = $db->sql_query($sql2) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic last replier fail', __LINE__, __FILE__, $sql2);
}

$r_row2 = $db->sql_fetchrow($r_result2);

$replier_id2 = $r_row2['user_id'];
$replier_name2 = ( $replier_id2 != ANONYMOUS ) ? $r_row2['username'] : ( !$r_row2['post_username'] ? $lang['Guest'] : $r_row2['post_username']);
$replier_url2 = ( $replier_id2 != ANONYMOUS && !$r_row2['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$replier_id") . '">' . "$replier_name2</a>") : $replier_name2;

$last_post_url2 = append_sid("viewtopic.$phpEx?p=$topic_last_post_id2#$topic_last_post_id2");

$template->assign_block_vars("toprow_reply", array(
'FORUM_NAME2' => $rows2['forum_name'],
'FORUM_URL2' => $forum_url2,
'TOPIC' => cutStr($rows2['topic_title']),
'TOPIC_URL2' => $topic_url2,
'TOPIC_VIEWS2' => $rows2['topic_views'],
'TOPIC_REPLIES2' => $rows2['topic_replies'],
'POST_TIME2' => create_date('Y-m-d', $r_row2['post_time'], $board_config['board_timezone']),
'POSTER_URL2' => $poster_url2,
'REPLIER_URL2' => $replier_url2,
'LAST_POST_URL2' => $last_post_url2
));
}

// 最多觀看
// query
$sql3 = "SELECT t.topic_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.forum_id = f.forum_id
AND topic_moved_id = '0'
$auth_forums_top5
ORDER BY $sortby3 DESC LIMIT 0, $MAX_TOPICS3";

if( !$result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic info fail', __LINE__, __FILE__, $sql3);
}

// fetch rows
while( $rows3 = $db->sql_fetchrow($result3) )
{
$topic_url3 = append_sid("viewtopic.$phpEx?t=" . $rows3['topic_id']);
$forum_url3 = append_sid("viewforum.$phpEx?f=" . $rows3['forum_id']);

$topic_poster3 = $rows3['topic_poster'];
$topic_last_post_id3 = $rows3['topic_last_post_id'];

// Grab topic poster and last replier data

$sql3 = "SELECT post_username, user_id, username
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE topic_id = '" . $rows3['topic_id'] . "'
AND poster_id = user_id
ORDER BY post_id LIMIT 0, 1";

if( !$p_result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic poster fail', __LINE__, __FILE__, $sql3);
}

$p_row3 = $db->sql_fetchrow($p_result3);

$poster_name3 = ( $topic_poster3 != ANONYMOUS ) ? $p_row3['username'] : ( !$p_row3['post_username'] ? $lang['Guest'] : $p_row3['post_username']);
$poster_url3 = ( $topic_poster3 != ANONYMOUS && !$p_row3['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$topic_poster") . '">' . "$poster_name3</a>") : $poster_name3;

/* 省略 主題發表人 查詢 */

$sql3 = "SELECT post_username, user_id, username, post_time
FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
WHERE post_id = '$topic_last_post_id3'
AND poster_id = user_id";

if( !$r_result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic last replier fail', __LINE__, __FILE__, $sql3);
}

$r_row3 = $db->sql_fetchrow($r_result3);

$replier_id3 = $r_row3['user_id'];
$replier_name3 = ( $replier_id3 != ANONYMOUS ) ? $r_row3['username'] : ( !$r_row3['post_username'] ? $lang['Guest'] : $r_row3['post_username']);
$replier_url3 = ( $replier_id3 != ANONYMOUS && !$r_row3['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$replier_id") . '">' . "$replier_name3</a>") : $replier_name3;

$last_post_url3 = append_sid("viewtopic.$phpEx?p=$topic_last_post_id3#$topic_last_post_id3");

$template->assign_block_vars("toprow_view", array(
'FORUM_NAME3' => $rows3['forum_name'],
'FORUM_URL3' => $forum_url3,
'TOPIC' => cutStr($rows3['topic_title']),
'TOPIC_URL3' => $topic_url3,
'TOPIC_VIEWS3' => $rows3['topic_views'],
'TOPIC_REPLIES3' => $rows3['topic_replies'],
'POST_TIME3' => create_date('Y-m-d', $r_row3['post_time'], $board_config['board_timezone']),
'POSTER_URL3' => $poster_url3,
'REPLIER_URL3' => $replier_url3,
'LAST_POST_URL3' => $last_post_url3
));
}
//
// - Better Toplist =====
//

#
#-----[ FIND ]------------------------------------------
#

'L_POSTS' => $lang['Posts'],

#
#-----[ AFTER, ADD ]------------------------------------------
#

'ICON_URL' => $images['icon_latest_reply'],
'ICON_ALT' => $lang['View_latest_post'],
'MAX_TOPICS' => $MAX_TOPICS,
'MAX_TOPICS2' => $MAX_TOPICS2,
'MAX_TOPICS3' => $MAX_TOPICS3,

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl

#
#-----[ FIND ]------------------------------------------
#

<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
</table>

#
#-----[ AFTER, ADD ]------------------------------------------
#

<table width="100%" border="0" cellpadding="4" cellspacing="1" width="" class="forumline">
<tr>
<th align="center" class="thCornerL">Icon</th>
<th align="center" class="thCornerL" width="30%">&nbsp;{L_FORUM}&nbsp;</th>
<th align="center" class="thTop" width="30%">&nbsp;{L_TOPICS}&nbsp;</th>
<th align="center" class="thTop" width="10%">&nbsp;&nbsp;{L_AUTHOR}&nbsp;&nbsp;</th>
<th align="center" class="thTop" width="5%">&nbsp;{L_REPLIES}&nbsp;</th>
<th align="center" class="thTop" width="5%">&nbsp;{L_VIEWS}&nbsp;</th>
<th align="center" class="thCornerR" width="20%">&nbsp;{L_LASTPOST}&nbsp;</th>
</tr>
<tr><td colspan="7" bgcolor="#FFFFFF" style="border-bottom: 1px dashed gray"><img src="images/topnew.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/>&nbsp;<span class="genmed"><b><font color="#FF3300">最新回覆文章</font></b>( <b>TOP {MAX_TOPICS} </b>)</span></td></tr>
<!-- BEGIN toprow -->
<tr>
<td class="row1"><span class="forumlink"><img src="templates/xand/images/top10.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/></span></td>
<td class="row1"><span class="forumlink"><a href="{toprow.FORUM_URL}" target="_top" class="forumlink">{toprow.FORUM_NAME}</a></span></td>
<td class="row2"><span class="topictitle"><a href="{toprow.TOPIC_URL}" target="_top" class="topictitle">{toprow.TOPIC}</a></span></td>
<td class="row1" align="center"><span class="name">{toprow.POSTER_URL}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow.TOPIC_REPLIES}</span></td>
<td class="row1" align="center"><span class="postdetails">{toprow.TOPIC_VIEWS}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow.POST_TIME}<br />{toprow.REPLIER_URL}&nbsp;<a href="{toprow.LAST_POST_URL}" target="_top"><img src="{ICON_URL}" border="0" alt="{ICON_ALT}" /></a></span></td>
</tr>
<!-- END toprow -->


<tr><td colspan="7" bgcolor="#FFFFFF" style="border-bottom: 1px dashed gray"><img src="images/topnew.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/>&nbsp;<span class="genmed"><b><font color="#FF3300">最多回覆文章</font></b>( <b>TOP {MAX_TOPICS2} </b> )</span></td></tr>
<!-- BEGIN toprow_reply -->
<tr>
<td class="row1"><span class="forumlink"><img src="templates/xand/images/top10.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/></span></td>
<td class="row1"><span class="forumlink"><a href="{toprow_reply.FORUM_URL2}" target="_top" class="forumlink">{toprow_reply.FORUM_NAME2}</a></span></td>
<td class="row2"><span class="topictitle"><a href="{toprow_reply.TOPIC_URL2}" target="_top" class="topictitle">{toprow_reply.TOPIC}</a></span></td>
<td class="row1" align="center"><span class="name">{toprow_reply.POSTER_URL2}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow_reply.TOPIC_REPLIES2}</span></td>
<td class="row1" align="center"><span class="postdetails">{toprow_reply.TOPIC_VIEWS2}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow_reply.POST_TIME2}<br />{toprow_reply.REPLIER_URL2}&nbsp;<a href="{toprow_reply.LAST_POST_URL2}" target="_top"><img src="{ICON_URL}" border="0" alt="{ICON_ALT}" /></a></span></td>
</tr>
<!-- END toprow_reply -->

<tr><td colspan="7" bgcolor="#FFFFFF" style="border-bottom: 1px dashed gray"><img src="images/topnew.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/>&nbsp;<span class="genmed"><b><font color="#FF3300">最多點閱文章</font></b>(<b> TOP {MAX_TOPICS3} </b>)</span></td></tr>
<!-- BEGIN toprow_view -->
<tr>
<td class="row1"><span class="forumlink"><img src="templates/xand/images/top10.gif" alt="{L_NO_NEW_POSTS}" align="absmiddle"/></span></td>
<td class="row1"><span class="forumlink"><a href="{toprow_view.FORUM_URL3}" target="_top" class="forumlink">{toprow_view.FORUM_NAME3}</a></span></td>
<td class="row2"><span class="topictitle"><a href="{toprow_view.TOPIC_URL3}" target="_top" class="topictitle">{toprow_view.TOPIC}</a></span></td>
<td class="row1" align="center"><span class="name">{toprow_view.POSTER_URL3}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow_view.TOPIC_REPLIES3}</span></td>
<td class="row1" align="center"><span class="postdetails">{toprow_view.TOPIC_VIEWS3}</span></td>
<td class="row2" align="center"><span class="postdetails">{toprow_view.POST_TIME3}<br />{toprow_view.REPLIER_URL3}&nbsp;<a href="{toprow_view.LAST_POST_URL3}" target="_top"><img src="{ICON_URL}" border="0" alt="{ICON_ALT}" /></a></span></td>
</tr>
<!-- END toprow_view -->


</table>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:心靈兄:

我了解了....感謝....我用您的外掛也改良了一個直式的..並將Toplist 變數增加(讓Top 數可彈性修改)..希望有需要的人也可以使用.

範例: http://www.sonydslr.com.tw
這種 (分成三個表格) 排法我原先用過 (只是沒有加入Top 數可彈性修改).

我只是考量幾個因素後, 註解部分語法;
若您有需要, 則可自行 '移除註解' 使用.

ps.
1. 為了減少資料庫的查詢次數
2. 為了縮短首頁版面長度
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

To davidhuang:

抱歉! 我又發現錯誤:
最多回覆, 以及最多觀看的 (發表者) 最後發表者, 其連結 ID 有誤. :oops:
http://phpbb-tw.net/phpbb/viewtopic.php?p=256032#256032
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
davidhuang
星球公民
星球公民
文章: 33
註冊時間: 2007-01-31 13:29

文章 davidhuang »

心靈捕手 寫:To davidhuang:

抱歉! 我又發現錯誤:
最多回覆, 以及最多觀看的 (發表者) 最後發表者, 其連結 ID 有誤. :oops:
http://phpbb-tw.net/phpbb/viewtopic.php?p=256032#256032
謝謝 心靈 兄, 已經改好了, 但我今天去逛您的討論區, 發現您的 TopList 都是以 7天內排序, 可以請問您如何修改嗎??

還有一個題外問題是, 安裝 PHPBB...標準似乎都會有 "新文章" & "沒有新文章" 的圖示, 但我一直不懂 "新文章" & "沒有新文章" 的定義是什麼, 新發的文就是新文章嗎??...我用甲帳號登入發文, 用乙帳號進來看...一樣沒有新文章..... :cry:

而這定義新文章的資料庫欄位是在那裡呢??

有沒有MOD可以做到讓每個使用者知道那一篇文章他還沒閱讀過??

對不起胡亂問了一堆....真的很麻煩您..... :-D
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8538
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

davidhuang 寫:
心靈捕手 寫:To davidhuang:

抱歉! 我又發現錯誤:
最多回覆, 以及最多觀看的 (發表者) 最後發表者, 其連結 ID 有誤. :oops:
http://phpbb-tw.net/phpbb/viewtopic.php?p=256032#256032
謝謝 心靈 兄, 已經改好了, 但我今天去逛您的討論區, 發現您的 TopList 都是以 7天內排序, 可以請問您如何修改嗎??

還有一個題外問題是, 安裝 PHPBB...標準似乎都會有 "新文章" & "沒有新文章" 的圖示, 但我一直不懂 "新文章" & "沒有新文章" 的定義是什麼, 新發的文就是新文章嗎??...我用甲帳號登入發文, 用乙帳號進來看...一樣沒有新文章..... :cry:

而這定義新文章的資料庫欄位是在那裡呢??

有沒有MOD可以做到讓每個使用者知道那一篇文章他還沒閱讀過??

對不起胡亂問了一堆....真的很麻煩您..... :-D
1. '以 7天內排序' 構想來自此文.
http://phpbb-tw.net/phpbb/viewtopic.php?t=29129
外掛已更新...
http://phpbb-tw.net/phpbb/viewtopic.php?p=256071#256071

2. 版面新文章定義:
自您上回 '登出', 至您這回 '登入' 期間, 版面有發表新文章.
其 index.php 控制的程式碼如下:

代碼: 選擇全部

	if ($userdata['session_logged_in'])
	{
		// 60 days limit
		if ($userdata['user_lastvisit'] < (time() - 5184000))
		{
			$userdata['user_lastvisit'] = time() - 5184000;
		}
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
			WHERE p.post_id = t.topic_last_post_id 
				AND p.post_time > " . $userdata['user_lastvisit'] . " 
				AND t.topic_moved_id = 0"; 
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		$new_topic_data = array();
		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
		$db->sql_freeresult($result);
	}
如果硬要說有 '定義新文章的資料庫欄位',
那麼應該算是資料表 'phpbb_users' 的欄位 'user_lastvisit'.
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
主題已鎖定

回到「外掛問題討論」